github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/cli/command/stack/swarm/deploy_bundlefile_test.go (about) 1 package swarm 2 3 import ( 4 "bytes" 5 "path/filepath" 6 "testing" 7 8 "gotest.tools/assert" 9 is "gotest.tools/assert/cmp" 10 ) 11 12 func TestLoadBundlefileErrors(t *testing.T) { 13 testCases := []struct { 14 namespace string 15 path string 16 expectedError string 17 }{ 18 { 19 namespace: "namespace_foo", 20 expectedError: "Bundle namespace_foo.dab not found", 21 }, 22 { 23 namespace: "namespace_foo", 24 path: "invalid_path", 25 expectedError: "Bundle invalid_path not found", 26 }, 27 // FIXME: this test never working, testdata file is missing from repo 28 //{ 29 // namespace: "namespace_foo", 30 // path: string(golden.Get(t, "bundlefile_with_invalid_syntax")), 31 // expectedError: "Error reading", 32 //}, 33 } 34 35 for _, tc := range testCases { 36 _, err := loadBundlefile(&bytes.Buffer{}, tc.namespace, tc.path) 37 assert.ErrorContains(t, err, tc.expectedError) 38 } 39 } 40 41 func TestLoadBundlefile(t *testing.T) { 42 buf := new(bytes.Buffer) 43 44 namespace := "" 45 path := filepath.Join("testdata", "bundlefile_with_two_services.dab") 46 bundleFile, err := loadBundlefile(buf, namespace, path) 47 48 assert.NilError(t, err) 49 assert.Check(t, is.Equal(len(bundleFile.Services), 2)) 50 }