github.com/sleungcy-sap/cli@v7.1.0+incompatible/util/manifest/manifest_windows_test.go (about)

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