forked from billcobbler/casbin-redis-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions_test.go
More file actions
43 lines (33 loc) · 941 Bytes
/
Copy pathoptions_test.go
File metadata and controls
43 lines (33 loc) · 941 Bytes
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
package rediswatcher
import "testing"
func TestOptions(t *testing.T) {
o := WatcherOptions{
Channel: "ch1",
Password: "pa1",
Protocol: "pr1",
}
// test single option
o.optionBuilder(Channel("ch2"))
if o.Channel != "ch2" {
t.Errorf("Channel should be 'ch2', received '%s' instead", o.Channel)
}
if o.Password != "pa1" {
t.Errorf("Password should be 'pa1', received '%s' instead", o.Password)
}
// test multiple options
o.optionBuilder(Channel("ch3"), Password("pa3"), Protocol("pr3"))
if o.Channel != "ch3" {
t.Errorf("Channel should be 'ch3', received '%s' instead", o.Channel)
}
if o.Password != "pa3" {
t.Errorf("Password should be 'pa3', received '%s' instead", o.Password)
}
if o.Protocol != "pr3" {
t.Errorf("Protocol should be 'pr3', received '%s' instead", o.Password)
}
}
func (o *WatcherOptions) optionBuilder(setters ...WatcherOption) {
for _, setter := range setters {
setter(o)
}
}