@@ -173,86 +173,6 @@ func TestInspectApp(t *testing.T) {
173173 golden .Assert (t , output , "app-inspect.golden" )
174174}
175175
176- func TestBundle (t * testing.T ) {
177- cmd , cleanup := dockerCli .createTestCmd ()
178- defer cleanup ()
179-
180- tmpDir := fs .NewDir (t , t .Name ())
181- defer tmpDir .Remove ()
182-
183- // Running a docker in docker to bundle the application
184- dind := NewContainer ("docker:18.09-dind" , 2375 )
185- dind .Start (t )
186- defer dind .Stop (t )
187-
188- // Create a build context
189- cmd .Command = dockerCli .Command ("context" , "create" , "build-context" , "--docker" , fmt .Sprintf (`"host=tcp://%s"` , dind .GetAddress (t )))
190- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
191-
192- // The dind doesn't have the cnab-app-base image so we save it in order to load it later
193- cmd .Command = dockerCli .Command ("save" , fmt .Sprintf ("docker/cnab-app-base:%s" , internal .Version ), "--output" , tmpDir .Join ("cnab-app-base.tar.gz" ))
194- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
195-
196- cmd .Env = append (cmd .Env , "DOCKER_CONTEXT=build-context" )
197- cmd .Command = dockerCli .Command ("load" , "-i" , tmpDir .Join ("cnab-app-base.tar.gz" ))
198- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
199-
200- testCases := []struct {
201- name string
202- cmd []string
203- invocImage string
204- expectedBundle string
205- }{
206- {
207- name : "simple-bundle" ,
208- cmd : dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--output" , tmpDir .Join ("simple-bundle.json" )),
209- invocImage : "simple:1.1.0-beta1-invoc" ,
210- expectedBundle : "simple-bundle.json.golden" ,
211- },
212- {
213- name : "bundle-with-tag" ,
214- cmd : dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "myimage:mytag" , "--output" , tmpDir .Join ("bundle-with-tag.json" )),
215- invocImage : "myimage:mytag-invoc" ,
216- expectedBundle : "bundle-with-tag.json.golden" ,
217- },
218- }
219- for _ , tc := range testCases {
220- t .Run (tc .name , func (t * testing.T ) {
221- testDir := fs .NewDir (t , "" )
222- defer testDir .Remove ()
223-
224- // Bundle the docker application package to a CNAB bundle, using the build-context.
225- cmd .Command = tc .cmd
226- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
227-
228- // Check the resulting CNAB bundle.json
229- golden .Assert (t , string (golden .Get (t , tmpDir .Join (tc .name + ".json" ))), tc .expectedBundle )
230-
231- // List the images on the build context daemon and checks the invocation image is there
232- cmd .Command = dockerCli .Command ("image" , "ls" , "--format" , "{{.Repository}}:{{.Tag}}" )
233- icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 0 , Out : tc .invocImage })
234-
235- // Copy all the files from the invocation image and check them
236- cmd .Command = dockerCli .Command ("create" , "--name" , "invocation" , tc .invocImage )
237- id := strings .TrimSpace (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Stdout ())
238- cmd .Command = dockerCli .Command ("cp" , "invocation:/cnab/app/simple.dockerapp" , testDir .Join ("simple.dockerapp" ))
239- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
240- cmd .Command = dockerCli .Command ("rm" , "--force" , id )
241- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
242-
243- appDir := filepath .Join ("testdata" , "simple" , "simple.dockerapp" )
244- manifest := fs .Expected (
245- t ,
246- fs .WithMode (0755 ),
247- fs .WithFile (internal .MetadataFileName , readFile (t , filepath .Join (appDir , internal .MetadataFileName )), fs .WithMode (0644 )),
248- fs .WithFile (internal .ComposeFileName , readFile (t , filepath .Join (appDir , internal .ComposeFileName )), fs .WithMode (0644 )),
249- fs .WithFile (internal .ParametersFileName , readFile (t , filepath .Join (appDir , internal .ParametersFileName )), fs .WithMode (0644 )),
250- )
251- assert .Assert (t , fs .Equal (testDir .Join ("simple.dockerapp" ), manifest ))
252- })
253- }
254- }
255-
256176func TestDockerAppLifecycle (t * testing.T ) {
257177 t .Run ("withBindMounts" , func (t * testing.T ) {
258178 testDockerAppLifecycle (t , true )
0 commit comments