github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/util/manifest/manifest_windows_test.go (about) 1 //go:build windows 2 // +build windows 3 4 package manifest_test 5 6 import ( 7 "io/ioutil" 8 "os" 9 "path/filepath" 10 11 . "code.cloudfoundry.org/cli/util/manifest" 12 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 ) 16 17 var _ = Describe("Manifest with paths", func() { 18 var ( 19 pathToManifest string 20 manifest string 21 ) 22 23 JustBeforeEach(func() { 24 tempFile, err := ioutil.TempFile("", "manifest-test-") 25 Expect(err).ToNot(HaveOccurred()) 26 Expect(tempFile.Close()).ToNot(HaveOccurred()) 27 pathToManifest = tempFile.Name() 28 29 err = ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) 30 Expect(err).ToNot(HaveOccurred()) 31 }) 32 33 AfterEach(func() { 34 Expect(os.RemoveAll(pathToManifest)).ToNot(HaveOccurred()) 35 }) 36 37 Describe("ReadAndInterpolateManifest", func() { 38 var ( 39 apps []Application 40 executeErr error 41 ) 42 43 JustBeforeEach(func() { 44 apps, executeErr = ReadAndInterpolateManifest(pathToManifest, nil, nil) 45 }) 46 47 BeforeEach(func() { 48 manifest = `--- 49 applications: 50 - name: "app-1" 51 path: C:\foo 52 - name: "app-2" 53 path: bar 54 - name: "app-3" 55 path: ..\baz 56 ` 57 }) 58 59 It("reads the manifest file", func() { 60 tempDir := filepath.Dir(pathToManifest) 61 parentTempDir := filepath.Dir(tempDir) 62 Expect(executeErr).ToNot(HaveOccurred()) 63 Expect(apps).To(ConsistOf( 64 Application{Name: "app-1", Path: "C:\\foo"}, 65 Application{Name: "app-2", Path: filepath.Join(tempDir, "bar")}, 66 Application{Name: "app-3", Path: filepath.Join(parentTempDir, "baz")}, 67 )) 68 }) 69 }) 70 })