-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathschedules_test.go
50 lines (37 loc) · 1.46 KB
/
schedules_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
package securityspy_test
import (
"encoding/xml"
"net/url"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"golift.io/securityspy"
"golift.io/securityspy/mocks"
"golift.io/securityspy/server"
)
func TestSetSchedulePreset(t *testing.T) {
t.Parallel()
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
assert := assert.New(t)
server := securityspy.NewMust(
&server.Config{Username: "user", Password: "pass", URL: "http://127.0.0.1:5678", VerifySSL: false})
fake := mocks.NewMockAPI(mockCtrl) // create a fake api interface that provides introspection methods.
server.API = fake // override our internal api interface with a fake interface.
fake.EXPECT().SimpleReq("++ssSetPreset", url.Values{"id": []string{"1"}}, -1)
assert.Nil(server.SetSchedulePreset(1), "this method must not return an error during testing")
}
func TestUnmarshalXMLscheduleContainer(t *testing.T) {
t.Parallel()
assert := assert.New(t)
var s securityspy.ScheduleContainer
err := xml.Unmarshal([]byte(testScheduleList), &s)
assert.Nil(err, "valid data must not produce an error")
assert.Equal("Armed 24/7", s[1], "the scheduleContainer data did not unmarshal properly")
assert.Equal(6, len(s))
err = xml.Unmarshal([]byte("<gotrekt>"), &s)
assert.NotNil(err, "invalid data must produce an error")
err = xml.Unmarshal([]byte("<gotrekt><server></gotrekt>"), &s)
assert.NotNil(err, "invalid data must produce an error")
}
/**/