File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,24 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
+ func TestFilterWatches (t * testing.T ) {
10
+ testConfigFile := & ConfigFile {
11
+ Config : []Config {
12
+ {Template : "foo" , Watch : true },
13
+ {Template : "bar" },
14
+ {Template : "baz" , Watch : true },
15
+ },
16
+ }
17
+
18
+ expected := []Config {
19
+ {Template : "foo" , Watch : true },
20
+ {Template : "baz" , Watch : true },
21
+ }
22
+
23
+ configFile := testConfigFile .FilterWatches ()
24
+ assert .Equal (t , expected , configFile .Config )
25
+ }
26
+
9
27
func TestParseWait (t * testing.T ) {
10
28
incorrectIntervals := []string {
11
29
"500x" , // Incorrect min interval
Original file line number Diff line number Diff line change @@ -163,3 +163,39 @@ func TestPublishedAddresses(t *testing.T) {
163
163
164
164
assert .ElementsMatch (t , expected , container .PublishedAddresses ())
165
165
}
166
+
167
+ func TestRuntimeContainerEquals (t * testing.T ) {
168
+ rc1 := & RuntimeContainer {
169
+ ID : "baz" ,
170
+ Image : DockerImage {
171
+ Registry : "foo/bar" ,
172
+ },
173
+ }
174
+ rc2 := & RuntimeContainer {
175
+ ID : "baz" ,
176
+ Name : "qux" ,
177
+ Image : DockerImage {
178
+ Registry : "foo/bar" ,
179
+ },
180
+ }
181
+ assert .True (t , rc1 .Equals (* rc2 ))
182
+ assert .True (t , rc2 .Equals (* rc1 ))
183
+
184
+ rc2 .Image .Tag = "quux"
185
+ assert .False (t , rc1 .Equals (* rc2 ))
186
+ assert .False (t , rc2 .Equals (* rc1 ))
187
+ }
188
+
189
+ func TestDockerImageString (t * testing.T ) {
190
+ image := & DockerImage {Repository : "foo/bar" }
191
+ assert .Equal (t , "foo/bar" , image .String ())
192
+
193
+ image .Registry = "baz.io"
194
+ assert .Equal (t , "baz.io/foo/bar" , image .String ())
195
+
196
+ image .Tag = "qux"
197
+ assert .Equal (t , "baz.io/foo/bar:qux" , image .String ())
198
+
199
+ image .Registry = ""
200
+ assert .Equal (t , "foo/bar:qux" , image .String ())
201
+ }
Original file line number Diff line number Diff line change 1
1
package utils
2
2
3
3
import (
4
+ "io/ioutil"
5
+ "os"
4
6
"testing"
7
+
8
+ "github.com/stretchr/testify/assert"
5
9
)
6
10
7
11
func TestSplitKeyValueSlice (t * testing.T ) {
@@ -23,3 +27,19 @@ func TestSplitKeyValueSlice(t *testing.T) {
23
27
24
28
}
25
29
}
30
+
31
+ func TestPathExists (t * testing.T ) {
32
+ file , err := ioutil .TempFile ("" , "test" )
33
+ if err != nil {
34
+ t .Fatal (err )
35
+ }
36
+ defer os .Remove (file .Name ())
37
+
38
+ exists , err := PathExists (file .Name ())
39
+ assert .NoError (t , err )
40
+ assert .True (t , exists )
41
+
42
+ exists , err = PathExists ("/wrong/path" )
43
+ assert .NoError (t , err )
44
+ assert .False (t , exists )
45
+ }
You can’t perform that action at this time.
0 commit comments