-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomainify_test.go
More file actions
66 lines (51 loc) · 1.24 KB
/
domainify_test.go
File metadata and controls
66 lines (51 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"flag"
"path/filepath"
"testing"
"github.com/ProfoundNetworks/gpntest"
)
var binary_name string = "domainify"
var update *bool
func init() {
testing.Init()
update = flag.Bool("u", false, "update .golden files")
flag.Parse()
}
func TestDomainifyArgs(t *testing.T) {
t.Parallel()
var tests = []struct {
args string
want string
}{
{"www.profound.net", "profound.net\n"},
{"www.futurium.ec.europa.eu home.dotdashmeredith.mediaroom.com",
"futurium.ec.europa.eu\ndotdashmeredith.mediaroom.com\n"},
{"www.openfusion.com.au com", "openfusion.com.au\n\n"},
}
cmd0 := gpntest.FindBinary(t, binary_name)
for _, tc := range tests {
cmd := cmd0 + " " + tc.args
got := gpntest.MustExecuteCommand(t, cmd)
if string(got) != tc.want {
t.Errorf("want %q, got %q", tc.want, got)
}
}
}
func TestDomainStdin(t *testing.T) {
t.Parallel()
var tests = []struct {
infile string
}{
{"test1.txt"},
{"readme.txt"},
}
cmd0 := gpntest.FindBinary(t, binary_name)
for _, tc := range tests {
cmd := cmd0 + " --stdin <" +
filepath.Join("testdata", tc.infile)
got := gpntest.MustExecuteCommand(t, cmd)
gpntest.UpdateGolden(t, update, tc.infile, got)
gpntest.CompareFiles(t, tc.infile, tc.infile, got)
}
}