-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloopify_test.go
More file actions
81 lines (76 loc) · 2.36 KB
/
loopify_test.go
File metadata and controls
81 lines (76 loc) · 2.36 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package loopia
import (
"testing"
)
func minInt(a, b int) int {
if a < b {
return a
}
return b
}
func Test_loopify(t *testing.T) {
type args struct {
name string
zone string
}
tests := []struct {
name string
args args
wantName string
wantZone string
}{
{"simple", args{"some", "example.org"}, "some", "example.org"},
{"ending-dot", args{"some", "example.org."}, "some", "example.org."},
{"complex-left", args{"some.lcl", "example.org"}, "some.lcl", "example.org"},
{"complex-right", args{"some", "lcl.example.org"}, "some.lcl", "example.org"},
{"complex-right-dot", args{"some", "lcl.example.org."}, "some.lcl", "example.org."},
{"simple-blank-name", args{"", "example.org"}, "", "example.org"},
{"complex-blank-name", args{"", "lcl.example.org"}, ".lcl", "example.org"},
{"asdf", args{"", "stuff.lcl.example.org"}, ".stuff.lcl", "example.org"},
{"asdf", args{"some", "stuff.lcl.example.org"}, "some.stuff.lcl", "example.org"},
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := loopify(tt.args.name, tt.args.zone)
if got != tt.wantName {
t.Errorf("loopify() gotName = %v, wantName %v", got, tt.wantName)
}
if got1 != tt.wantZone {
t.Errorf("loopifyFQDN() gotZone = %v, wantZone %v", got1, tt.wantZone)
}
})
}
}
func Test_unLoopify(t *testing.T) {
type args struct {
name string
zone string
}
tests := []struct {
name string
args args
nameWant string
zoneWant string
}{
{"simple", args{"some", "example.org"}, "some", "example.org"},
{"ending-dot", args{"some", "example.org."}, "some", "example.org."},
{"complex-left", args{"some", "lcl.example.org"}, "some", "lcl.example.org"},
{"complex-right", args{"some", "lcl.example.org"}, "some", "lcl.example.org"},
{"complex-right-dot", args{"some", "lcl.example.org."}, "some", "lcl.example.org."},
{"a", args{"some.lcl", "example.org"}, "some", "lcl.example.org"},
{"b", args{"some.lcl", "example.org."}, "some", "lcl.example.org."},
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := unLoopify(tt.args.name, tt.args.zone)
if got != tt.nameWant {
t.Errorf("unLoopify() name got = %v, want %v", got, tt.nameWant)
}
if got1 != tt.zoneWant {
t.Errorf("unLoopify() zone got = %v, want %v", got1, tt.zoneWant)
}
})
}
}