-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfallback_test.go
44 lines (42 loc) · 923 Bytes
/
fallback_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
package vresolver
import "testing"
func TestFallback(t *testing.T) {
tests := []struct {
name string
fallback string
input string
want string
}{
{
name: "empty fallback and input return empty version",
fallback: "",
input: "",
want: "",
},
{
name: "empty fallback and non-empty input pass input as version",
fallback: "",
input: "foo",
want: "foo",
},
{
name: "non-empty fallback and non-empty input return input as version",
fallback: "bar",
input: "foo",
want: "foo",
},
{
name: "non-empty fallback and empty input return fallback as version",
fallback: "bar",
input: "",
want: "bar",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Fallback(tt.fallback)(tt.input); got != tt.want {
t.Errorf("Fallback() = %v, want %v", got, tt.want)
}
})
}
}