66 "os"
77 "path/filepath"
88 "regexp"
9- "runtime"
109 "strings"
1110 "testing"
1211
@@ -20,20 +19,6 @@ import (
2019 "gotest.tools/skip"
2120)
2221
23- const (
24- singleFileApp = `version: 0.1.0
25- name: helloworld
26- description: "hello world app"
27- namespace: "foo"
28- ---
29- version: '3.5'
30- services:
31- hello-world:
32- image: hello-world
33- ---
34- # This section contains the default values for your application parameters.`
35- )
36-
3722func TestRenderTemplates (t * testing.T ) {
3823 skip .If (t , ! hasExperimental , "experimental mode needed for this test" )
3924 appsPath := filepath .Join ("testdata" , "templates" )
@@ -226,56 +211,6 @@ func TestSplitMerge(t *testing.T) {
226211 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
227212}
228213
229- func TestURL (t * testing.T ) {
230- url := "https://raw.githubusercontent.com/docker/app/v0.4.1/examples/hello-world/hello-world.dockerapp"
231- result := icmd .RunCommand (dockerApp , "inspect" , url ).Assert (t , icmd .Success )
232- golden .Assert (t , result .Combined (), "helloworld-inspect.golden" )
233- }
234-
235- func TestWithRegistry (t * testing.T ) {
236- r := startRegistry (t )
237- defer r .Stop (t )
238- registry := r .GetAddress (t )
239- // push to a registry
240- icmd .RunCommand (dockerApp , "push" , "--namespace" , registry + "/myuser" , "testdata/render/envvariables/my.dockerapp" ).Assert (t , icmd .Success )
241- icmd .RunCommand (dockerApp , "push" , "--namespace" , registry + "/myuser" , "-t" , "latest" , "testdata/render/envvariables/my.dockerapp" ).Assert (t , icmd .Success )
242- icmd .RunCommand (dockerApp , "inspect" , registry + "/myuser/my.dockerapp:0.1.0" ).Assert (t , icmd .Success )
243- icmd .RunCommand (dockerApp , "inspect" , registry + "/myuser/my.dockerapp" ).Assert (t , icmd .Success )
244- icmd .RunCommand (dockerApp , "inspect" , registry + "/myuser/my" ).Assert (t , icmd .Success )
245- icmd .RunCommand (dockerApp , "inspect" , registry + "/myuser/my:0.1.0" ).Assert (t , icmd .Success )
246- // push a single-file app to a registry
247- dir := fs .NewDir (t , "save-prepare-build" , fs .WithFile ("my.dockerapp" , singleFileApp ))
248- defer dir .Remove ()
249- icmd .RunCommand (dockerApp , "push" , "--namespace" , registry + "/myuser" , dir .Join ("my.dockerapp" )).Assert (t , icmd .Success )
250-
251- // push with custom repo name
252- icmd .RunCommand (dockerApp , "push" , "-t" , "marshmallows" , "--namespace" , registry + "/rainbows" , "--repo" , "unicorns" , "testdata/render/envvariables/my.dockerapp" ).Assert (t , icmd .Success )
253- icmd .RunCommand (dockerApp , "inspect" , registry + "/rainbows/unicorns:marshmallows" ).Assert (t , icmd .Success )
254- }
255-
256- func TestAttachmentsWithRegistry (t * testing.T ) {
257- r := startRegistry (t )
258- defer r .Stop (t )
259- registry := r .GetAddress (t )
260-
261- dir := fs .NewDir (t , "testattachments" ,
262- fs .WithDir ("attachments.dockerapp" , fs .FromDir ("testdata/attachments.dockerapp" )),
263- )
264- defer dir .Remove ()
265-
266- icmd .RunCommand (dockerApp , "push" , "--namespace" , registry + "/acmecorp" , dir .Join ("attachments.dockerapp" )).Assert (t , icmd .Success )
267-
268- // inspect will run the core pull code too
269- result := icmd .RunCommand (dockerApp , "inspect" , registry + "/acmecorp/attachments.dockerapp:0.1.0" )
270-
271- result .Assert (t , icmd .Success )
272- resultOutput := result .Combined ()
273-
274- assert .Assert (t , strings .Contains (resultOutput , "config.cfg" ))
275- assert .Assert (t , strings .Contains (resultOutput , "nesteddir/config2.cfg" ))
276- assert .Assert (t , strings .Contains (resultOutput , "nesteddir/nested2/nested3/config3.cfg" ))
277- }
278-
279214func TestBundle (t * testing.T ) {
280215 tmpDir := fs .NewDir (t , t .Name ())
281216 defer tmpDir .Remove ()
@@ -312,9 +247,11 @@ func TestBundle(t *testing.T) {
312247
313248 // Copy all the files from the invocation image and check them
314249 cmd .Command = []string {dockerCli , "create" , "--name" , "invocation" , "acmecorp/simple:1.1.0-beta1-invoc" }
315- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
250+ id := strings . TrimSpace ( icmd .RunCmd (cmd ).Assert (t , icmd .Success ). Stdout () )
316251 cmd .Command = []string {dockerCli , "cp" , "invocation:/cnab/app/simple.dockerapp" , tmpDir .Join ("simple.dockerapp" )}
317252 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
253+ cmd .Command = []string {dockerCli , "rm" , "--force" , id }
254+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
318255
319256 appDir := filepath .Join ("testdata" , "simple" , "simple.dockerapp" )
320257 manifest := fs .Expected (
@@ -333,19 +270,11 @@ func TestDockerAppLifecycle(t *testing.T) {
333270 defer tmpDir .Remove ()
334271
335272 cmd := icmd.Cmd {
336- Env : [] string {
273+ Env : append ( os . Environ (),
337274 fmt .Sprintf ("DUFFLE_HOME=%s" , tmpDir .Path ()),
338275 fmt .Sprintf ("DOCKER_CONFIG=%s" , tmpDir .Path ()),
339276 "DOCKER_TARGET_CONTEXT=swarm-target-context" ,
340- },
341- }
342-
343- // We need to explicitly set the SYSTEMROOT on windows
344- // otherwise we get the error:
345- // "panic: failed to read random bytes: CryptAcquireContext: Provider DLL failed to initialize correctly."
346- // See: https://github.com/golang/go/issues/25210
347- if runtime .GOOS == "windows" {
348- cmd .Env = append (cmd .Env , `SYSTEMROOT=C:\WINDOWS` )
277+ ),
349278 }
350279
351280 // Running a swarm using docker in docker to install the application
0 commit comments