-
Notifications
You must be signed in to change notification settings - Fork 3
/
stream_test.go
137 lines (119 loc) · 3.53 KB
/
stream_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package p4
import (
"fmt"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestStream_Streams(t *testing.T) {
var (
si *StreamInfo
streams []*StreamInfo
stream = "//DM99.ZGame.Project/Development/ZGame_ArtDev"
)
conn, err := setup(t)
Convey("test Stream functions", t, func() {
So(err, ShouldBeNil)
Convey("List streams", func() {
streams, err = conn.Streams()
So(err, ShouldBeNil)
So(len(streams), ShouldBeGreaterThanOrEqualTo, 0)
})
Convey("Get stream info", func() {
si, err = conn.Stream(stream)
So(err, ShouldBeNil)
So(si.Stream, ShouldEqual, stream)
})
//Convey("Get non-exist stream info", func() {
// si, err = conn.Stream(stream + "/abc")
// So(err, ShouldNotBeNil)
//})
Convey("Delete stream", func() {
message, err := conn.DeleteStream(stream, true)
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s deleted.", stream))
})
Convey("Create stream", func() {
var (
name = "ZGame_ArtDev"
parent = "//DM99.ZGame.Project/Main/ZGame_Mainline"
streamType = "development"
)
message, err := conn.CreateStream(name, streamType, parent, stream, true)
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s saved.", stream))
})
Convey("Create stream mainline", func() {
var (
name = "ZGame_Mainline2"
mainline = "//DM02.Elrond.Project/Main/Mainline2"
streamType = "mainline"
)
// allsubmit unlocked toparent fromparent mergedown
message, err := conn.CreateStream(name, streamType, "", mainline, false)
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s saved.", mainline))
})
Convey("Create stream with invalid stream type", func() {
var (
name = "ZGame_ArtDev"
parent = "//DM99.ZGame.Project/Main/ZGame_Mainline"
streamType = "abc"
)
_, err := conn.CreateStream(name, streamType, parent, stream, true)
So(err, ShouldNotBeNil)
})
})
}
func TestStream_DeleteStream(t *testing.T) {
var (
message string
stream = "//DM99.ZGame.Project/Development/ZGame_June"
)
conn, err := setup(t)
Convey("test DeleteStream functions", t, func() {
So(err, ShouldBeNil)
Convey("Delete stream", func() {
message, err = conn.DeleteStream(stream, false)
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s deleted.", stream))
})
})
}
func TestStream_CreateVirtualStream(t *testing.T) {
var (
message string
stream = "//DM99.ZGame.Project/Virtual/ZGame_Virtual"
name = "ZGame_ArtDev"
parent = "//DM99.ZGame.Project/Main/ZGame_Mainline"
streamType = "development"
)
conn, err := setup(t)
Convey("test CreateStream functions", t, func() {
So(err, ShouldBeNil)
Convey("Delete stream", func() {
message, err = conn.DeleteStream(stream, true)
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s deleted.", stream))
})
Convey("Create stream", func() {
message, err = conn.CreateStream(name, streamType, parent, stream, true, WithOptions([]int{AllSubmit, UnLocked, ToParent, FromParent, MergeDown}))
So(err, ShouldBeNil)
So(message, ShouldEqual, fmt.Sprintf("Stream %s saved.", stream))
})
})
}
func TestStream_ImportStream(t *testing.T) {
var (
si *StreamInfo
stream = "//DM99.ZGame.Project/Main/ZGame_Mainline"
)
conn, err := setup(t)
Convey("test Get Stream functions", t, func() {
So(err, ShouldBeNil)
Convey("Get stream info", func() {
si, err = conn.Stream(stream)
So(err, ShouldBeNil)
So(si.Stream, ShouldEqual, stream)
})
})
}