-
Notifications
You must be signed in to change notification settings - Fork 3
/
triggers_test.go
44 lines (37 loc) · 997 Bytes
/
triggers_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
package p4
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestTriggers_Triggers(t *testing.T) {
var (
currentTriggers []string
lines = []string{
"swarm.commit change-commit //... \"%//.swarm/triggers/swarm-trigger.pl% -c %//.swarm/triggers/swarm-trigger.conf% -t commit -v %change%\"",
}
)
conn, err := setup(t)
Convey("test Triggers functions", t, func() {
So(err, ShouldBeNil)
Convey("List triggers", func() {
currentTriggers, err = conn.Triggers()
So(err, ShouldBeNil)
So(len(currentTriggers), ShouldBeGreaterThanOrEqualTo, 0)
})
Convey("Preview triggers", func() {
var (
triggers = &Triggers{Lines: lines}
)
content := triggers.String()
So(content, ShouldNotBeEmpty)
})
Convey("Write new triggers", func() {
_, err = conn.WriteTriggers(lines)
So(err, ShouldBeNil)
})
Convey("Restore old triggers", func() {
_, err = conn.WriteTriggers(currentTriggers)
So(err, ShouldBeNil)
})
})
}