@@ -33,17 +33,13 @@ import (
33
33
)
34
34
35
35
// This test used to be part of an integration style test in core/container, moved to here
36
- func TestRealPath (t * testing.T ) {
36
+ func TestIntegrationPath (t * testing.T ) {
37
37
coreutil .SetupTestConfig ()
38
38
ctxt := context .Background ()
39
39
dc := NewDockerVM ("" , "" )
40
40
ccid := ccintf.CCID {Name : "simple" }
41
- reader := getCodeChainBytesInMem ()
42
41
43
- err := dc .Deploy (ctxt , ccid , nil , nil , reader )
44
- require .NoError (t , err )
45
-
46
- err = dc .Start (ctxt , ccid , nil , nil , nil , nil )
42
+ err := dc .Start (ctxt , ccid , nil , nil , nil , InMemBuilder {})
47
43
require .NoError (t , err )
48
44
49
45
// Stop, killing, and deleting
@@ -85,34 +81,6 @@ func TestGetDockerHostConfig(t *testing.T) {
85
81
testutil .AssertEquals (t , hostConfig .CPUShares , int64 (1024 * 1024 * 1024 * 2 ))
86
82
}
87
83
88
- func Test_Deploy (t * testing.T ) {
89
- dvm := DockerVM {}
90
- ccid := ccintf.CCID {Name : "simple" }
91
- //get the tarball for codechain
92
- tarRdr := getCodeChainBytesInMem ()
93
- args := make ([]string , 1 )
94
- env := make ([]string , 1 )
95
- ctx := context .Background ()
96
-
97
- // getMockClient returns error
98
- getClientErr = true
99
- dvm .getClientFnc = getMockClient
100
- err := dvm .Deploy (ctx , ccid , args , env , tarRdr )
101
- testerr (t , err , false )
102
- getClientErr = false
103
-
104
- // Failure case: dockerClient.BuildImage returns error
105
- buildErr = true
106
- dvm .getClientFnc = getMockClient
107
- err = dvm .Deploy (ctx , ccid , args , env , tarRdr )
108
- testerr (t , err , false )
109
- buildErr = false
110
-
111
- // Success case
112
- err = dvm .Deploy (ctx , ccid , args , env , tarRdr )
113
- testerr (t , err , true )
114
- }
115
-
116
84
func Test_Start (t * testing.T ) {
117
85
dvm := DockerVM {}
118
86
ccid := ccintf.CCID {Name : "simple" }
@@ -213,30 +181,6 @@ func Test_Stop(t *testing.T) {
213
181
testerr (t , err , true )
214
182
}
215
183
216
- func Test_Destroy (t * testing.T ) {
217
- dvm := DockerVM {}
218
- ccid := ccintf.CCID {Name : "simple" }
219
- ctx := context .Background ()
220
-
221
- // Failure cases
222
- // Case 1: getMockClient returns error
223
- getClientErr = true
224
- dvm .getClientFnc = getMockClient
225
- err := dvm .Destroy (ctx , ccid , true , true )
226
- testerr (t , err , false )
227
- getClientErr = false
228
-
229
- // Case 2: dockerClient.RemoveImageExtended returns error
230
- removeImgErr = true
231
- err = dvm .Destroy (ctx , ccid , true , true )
232
- testerr (t , err , false )
233
- removeImgErr = false
234
-
235
- // Success case
236
- err = dvm .Destroy (ctx , ccid , true , true )
237
- testerr (t , err , true )
238
- }
239
-
240
184
type testCase struct {
241
185
name string
242
186
vm * DockerVM
@@ -314,7 +258,9 @@ func TestGetVMName(t *testing.T) {
314
258
assert.NotNil(t, err, "Expected error")
315
259
}*/
316
260
317
- func getCodeChainBytesInMem () io.Reader {
261
+ type InMemBuilder struct {}
262
+
263
+ func (imb InMemBuilder ) Build () (io.Reader , error ) {
318
264
startTime := time .Now ()
319
265
inputbuf := bytes .NewBuffer (nil )
320
266
gw := gzip .NewWriter (inputbuf )
@@ -327,7 +273,7 @@ func getCodeChainBytesInMem() io.Reader {
327
273
tr .Write ([]byte (dockerFileContents ))
328
274
tr .Close ()
329
275
gw .Close ()
330
- return inputbuf
276
+ return inputbuf , nil
331
277
}
332
278
333
279
func testerr (t * testing.T , err error , succ bool ) {
0 commit comments