github.com/thriqon/involucro@v1.1.3/integrationtest/flexible_mount_dir_test.go (about) 1 package integrationtest 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "github.com/involucro/involucro/app" 10 ) 11 12 func TestFlexibleMountDirs(t *testing.T) { 13 if testing.Short() { 14 t.SkipNow() 15 } 16 pwd, err := filepath.Abs(".") 17 if err != nil { 18 t.Fatal(err) 19 } 20 21 cases := []string{ 22 "./int21:/ttt", 23 pwd + "/int21:/ttt", 24 } 25 26 if err := os.MkdirAll("int21", 0755); err != nil { 27 t.Fatal(err) 28 } 29 30 for _, el := range cases { 31 if err := ioutil.WriteFile(filepath.Join(pwd, "int21", "testfile"), []byte{0}, 0755); err != nil { 32 t.Error("case failed", err) 33 continue 34 } 35 36 if err := app.Main([]string{ 37 "involucro", "-e", 38 "inv.task('p').using('busybox').withHostConfig({Binds = {'" + el + "'}}).run('rm', '/ttt/testfile')", 39 "p", 40 }); err != nil { 41 t.Fatal(err) 42 } 43 44 if _, err := os.Stat(filepath.Join(pwd, "int21", "testfile")); (err == nil) || (!os.IsNotExist(err)) { 45 t.Error("Unexpected error", err) 46 } 47 } 48 }