-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
63 lines (60 loc) · 1.25 KB
/
options_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
package brandalert
import (
"reflect"
"strconv"
"testing"
"time"
)
// TestOptions tests the Options functions.
func TestOptions(t *testing.T) {
tests := []struct {
name string
values *brandAlertRequest
option Option
want string
}{
{
name: "responseFormat",
values: &brandAlertRequest{},
option: OptionResponseFormat("json"),
want: "json",
},
{
name: "sinceDate",
values: &brandAlertRequest{},
option: OptionSinceDate(time.Date(2021, 01, 01, 0, 0, 0, 0, time.UTC)),
want: "2021-01-01",
},
{
name: "withTypos",
values: &brandAlertRequest{},
option: OptionWithTypos(true),
want: "true",
},
{
name: "punycode",
values: &brandAlertRequest{},
option: OptionPunycode(false),
want: "false",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var got string
tt.option(tt.values)
switch tt.name {
case "responseFormat":
got = tt.values.ResponseFormat
case "sinceDate":
got = tt.values.SinceDate
case "withTypos":
got = strconv.FormatBool(tt.values.WithTypos)
case "punycode":
got = strconv.FormatBool(tt.values.WithTypos)
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Option() = %v, want %v", got, tt.want)
}
})
}
}