-
Notifications
You must be signed in to change notification settings - Fork 4
/
joiner_test.go
70 lines (67 loc) · 1.27 KB
/
joiner_test.go
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
package unis
import (
"reflect"
"strings"
"testing"
)
func TestJoinerFunc_Join(t *testing.T) {
type args struct {
part1 string
part2 string
}
tests := []struct {
name string
j JoinerFunc
args args
want string
}{
{
"join1",
NewJoiner("/"),
args{
"file",
"path",
},
"file/path",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.j.Join(tt.args.part1, tt.args.part2); got != tt.want {
t.Errorf("JoinerFunc.Join() = %v, want %v", got, tt.want)
}
})
}
}
func TestNewJoinerChain(t *testing.T) {
type args struct {
joiner Joiner
processors []Processor
part1 string
part2 string
}
tests := []struct {
name string
args args
want string
}{
{
"joinerchain1",
args{
NewJoiner("/"),
[]Processor{ProcessorFunc(strings.ToLower), NewPrepender("http://")},
"the",
"path",
},
"http://the/path",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
joinerchain := NewJoinerChain(tt.args.joiner, tt.args.processors...)
if got := joinerchain.Join(tt.args.part1, tt.args.part2); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewJoinerChain().Join(%s, %s) = %v, want %v", tt.args.part1, tt.args.part2, got, tt.want)
}
})
}
}