-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservice_test.go
71 lines (50 loc) · 2.54 KB
/
service_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
package patrol
import (
"log"
"sabey.co/unittest"
"testing"
)
func TestPatrolService(t *testing.T) {
log.Println("TestPatrolService")
service := &ConfigService{
Management: 0,
}
unittest.Equals(t, service.Validate(), ERR_SERVICE_MANAGEMENT_INVALID)
service.Management = SERVICE_MANAGEMENT_SERVICE
unittest.Equals(t, service.Validate(), ERR_SERVICE_EMPTY)
service.Service = "1234567890123456790123456789012345678901234567890123456789012345"
unittest.Equals(t, service.Validate(), ERR_SERVICE_MAXLENGTH)
service.Service = "123456789012345679012345678901234567890123456789012345678901234"
unittest.Equals(t, service.Validate(), ERR_SERVICE_NAME_EMPTY)
service.Name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
unittest.Equals(t, service.Validate(), ERR_SERVICE_NAME_MAXLENGTH)
service.Name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
// start
service.IgnoreExitCodesStart = []uint8{0}
unittest.Equals(t, service.Validate(), ERR_SERVICE_INVALID_EXITCODE)
service.IgnoreExitCodesStart = []uint8{1, 1}
unittest.Equals(t, service.Validate(), ERR_SERVICE_DUPLICATE_EXITCODE)
service.IgnoreExitCodesStart = []uint8{2}
unittest.IsNil(t, service.Validate())
// status
service.IgnoreExitCodesStatus = []uint8{0}
unittest.Equals(t, service.Validate(), ERR_SERVICE_INVALID_EXITCODE)
service.IgnoreExitCodesStatus = []uint8{1, 1}
unittest.Equals(t, service.Validate(), ERR_SERVICE_DUPLICATE_EXITCODE)
service.IgnoreExitCodesStatus = []uint8{2}
unittest.IsNil(t, service.Validate())
// stop
service.IgnoreExitCodesStop = []uint8{0}
unittest.Equals(t, service.Validate(), ERR_SERVICE_INVALID_EXITCODE)
service.IgnoreExitCodesStop = []uint8{1, 1}
unittest.Equals(t, service.Validate(), ERR_SERVICE_DUPLICATE_EXITCODE)
service.IgnoreExitCodesStop = []uint8{2}
unittest.IsNil(t, service.Validate())
// restart
service.IgnoreExitCodesRestart = []uint8{0}
unittest.Equals(t, service.Validate(), ERR_SERVICE_INVALID_EXITCODE)
service.IgnoreExitCodesRestart = []uint8{1, 1}
unittest.Equals(t, service.Validate(), ERR_SERVICE_DUPLICATE_EXITCODE)
service.IgnoreExitCodesRestart = []uint8{2}
unittest.IsNil(t, service.Validate())
}