@@ -106,19 +106,19 @@ func Test_Start(t *testing.T) {
106
106
// case 1: getMockClient returns error
107
107
dvm .getClientFnc = getMockClient
108
108
getClientErr = true
109
- err := dvm .Start (ctx , ccid , args , env , nil )
109
+ err := dvm .Start (ctx , ccid , args , env , nil , nil )
110
110
testerr (t , err , false )
111
111
getClientErr = false
112
112
113
113
// case 2: dockerClient.CreateContainer returns error
114
114
createErr = true
115
- err = dvm .Start (ctx , ccid , args , env , nil )
115
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
116
116
testerr (t , err , false )
117
117
createErr = false
118
118
119
119
// case 3: dockerClient.CreateContainer returns docker.noSuchImgErr
120
120
noSuchImgErr = true
121
- err = dvm .Start (ctx , ccid , args , env , nil )
121
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
122
122
testerr (t , err , false )
123
123
124
124
chaincodePath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01"
@@ -136,35 +136,53 @@ func Test_Start(t *testing.T) {
136
136
// docker.noSuchImgErr and dockerClient.Start returns error
137
137
viper .Set ("vm.docker.attachStdout" , true )
138
138
startErr = true
139
- err = dvm .Start (ctx , ccid , args , env , bldr )
139
+ err = dvm .Start (ctx , ccid , args , env , bldr , nil )
140
140
testerr (t , err , false )
141
141
startErr = false
142
142
143
143
// Success cases
144
- err = dvm .Start (ctx , ccid , args , env , bldr )
144
+ err = dvm .Start (ctx , ccid , args , env , bldr , nil )
145
145
testerr (t , err , true )
146
146
noSuchImgErr = false
147
147
148
148
// dockerClient.StopContainer returns error
149
149
stopErr = true
150
- err = dvm .Start (ctx , ccid , args , env , nil )
150
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
151
151
testerr (t , err , true )
152
152
stopErr = false
153
153
154
154
// dockerClient.KillContainer returns error
155
155
killErr = true
156
- err = dvm .Start (ctx , ccid , args , env , nil )
156
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
157
157
testerr (t , err , true )
158
158
killErr = false
159
159
160
160
// dockerClient.RemoveContainer returns error
161
161
removeErr = true
162
- err = dvm .Start (ctx , ccid , args , env , nil )
162
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
163
163
testerr (t , err , true )
164
164
removeErr = false
165
165
166
- err = dvm .Start (ctx , ccid , args , env , nil )
166
+ err = dvm .Start (ctx , ccid , args , env , nil , nil )
167
167
testerr (t , err , true )
168
+
169
+ //test preLaunchFunc works correctly
170
+ preLaunchStr := "notset"
171
+ preLaunchFunc := func () error {
172
+ preLaunchStr = "set"
173
+ return nil
174
+ }
175
+
176
+ err = dvm .Start (ctx , ccid , args , env , nil , preLaunchFunc )
177
+ testerr (t , err , true )
178
+ assert .Equal (t , preLaunchStr , "set" )
179
+
180
+ preLaunchFunc = func () error {
181
+ return fmt .Errorf ("testing error path" )
182
+ }
183
+
184
+ err = dvm .Start (ctx , ccid , args , env , nil , preLaunchFunc )
185
+ testerr (t , err , false )
168
186
}
169
187
170
188
func Test_Stop (t * testing.T ) {
0 commit comments