-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_test.go
79 lines (60 loc) · 1.78 KB
/
config_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
71
72
73
74
75
76
77
78
79
package ibsync
import (
"testing"
"time"
)
func TestDefaultConfig(t *testing.T) {
config := NewConfig()
if config.Host != HOST {
t.Errorf("expected default Host to be %s, got %s", HOST, config.Host)
}
if config.Port != PORT {
t.Errorf("expected default Port to be %d, got %d", PORT, config.Port)
}
if config.ClientID < 1 || config.ClientID > 999999 {
t.Errorf("expected default ClientID to be between 1 and 999999, got %d", config.ClientID)
}
if !config.InSync {
t.Errorf("expected default InSync to be true, got %v", config.InSync)
}
if config.Timeout != TIMEOUT {
t.Errorf("expected default Timeout to be %v, got %v", TIMEOUT, config.Timeout)
}
}
func TestWithHost(t *testing.T) {
config := NewConfig(WithHost("192.168.1.1"))
if config.Host != "192.168.1.1" {
t.Errorf("expected Host to be %s, got %s", "192.168.1.1", config.Host)
}
}
func TestWithPort(t *testing.T) {
config := NewConfig(WithPort(4001))
if config.Port != 4001 {
t.Errorf("expected Port to be %d, got %d", 4001, config.Port)
}
}
func TestWithClientID(t *testing.T) {
config := NewConfig(WithClientID(12345))
if config.ClientID != 12345 {
t.Errorf("expected ClientID to be %d, got %d", 12345, config.ClientID)
}
}
func TestWithClientZero(t *testing.T) {
config := NewConfig(WithClientZero())
if config.ClientID != 0 {
t.Errorf("expected ClientID to be 0, got %d", config.ClientID)
}
}
func TestWithoutSync(t *testing.T) {
config := NewConfig(WithoutSync())
if config.InSync {
t.Errorf("expected InSync to be false, got %v", config.InSync)
}
}
func TestWithTimeout(t *testing.T) {
customTimeout := 15 * time.Second
config := NewConfig(WithTimeout(customTimeout))
if config.Timeout != customTimeout {
t.Errorf("expected Timeout to be %v, got %v", customTimeout, config.Timeout)
}
}