github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/actor/pushaction/merge_and_validate_settings_and_manifest_windows_test.go (about) 1 // +build windows 2 3 package pushaction_test 4 5 import ( 6 "path/filepath" 7 8 "code.cloudfoundry.org/cli/actor/actionerror" 9 . "code.cloudfoundry.org/cli/actor/pushaction" 10 "code.cloudfoundry.org/cli/util/manifest" 11 12 . "github.com/onsi/ginkgo" 13 . "github.com/onsi/ginkgo/extensions/table" 14 . "github.com/onsi/gomega" 15 ) 16 17 var _ = Describe("MergeAndValidateSettingsAndManifest", func() { 18 19 var ( 20 actor *Actor 21 cmdSettings CommandLineSettings 22 23 currentDirectory string 24 ) 25 26 BeforeEach(func() { 27 actor = NewActor(nil, nil, nil) 28 currentDirectory = getCurrentDir() 29 }) 30 31 Describe("sanitizing values", func() { 32 var ( 33 apps []manifest.Application 34 mergedApps []manifest.Application 35 executeErr error 36 ) 37 38 BeforeEach(func() { 39 cmdSettings = CommandLineSettings{ 40 CurrentDirectory: currentDirectory, 41 } 42 43 apps = []manifest.Application{ 44 {Name: "app-1"}, 45 } 46 }) 47 48 JustBeforeEach(func() { 49 mergedApps, executeErr = actor.MergeAndValidateSettingsAndManifests(cmdSettings, apps) 50 }) 51 52 Context("when app path '\\' is set from the command line", func() { 53 BeforeEach(func() { 54 cmdSettings.ProvidedAppPath = `\` 55 }) 56 57 It("sets the app path to the provided path", func() { 58 Expect(executeErr).ToNot(HaveOccurred()) 59 abs, err := filepath.Abs(`\`) 60 Expect(err).ToNot(HaveOccurred()) 61 Expect(mergedApps[0].Path).To(Equal(abs)) 62 }) 63 }) 64 65 Context("when app path '\\' is set from the manifest", func() { 66 BeforeEach(func() { 67 apps[0].Path = `\` 68 }) 69 70 It("sets the app path to the provided path", func() { 71 Expect(executeErr).ToNot(HaveOccurred()) 72 abs, err := filepath.Abs(`\`) 73 Expect(err).ToNot(HaveOccurred()) 74 Expect(mergedApps[0].Path).To(Equal(abs)) 75 }) 76 }) 77 }) 78 79 DescribeTable("validation errors", 80 func(settings CommandLineSettings, apps []manifest.Application, expectedErr error) { 81 _, err := actor.MergeAndValidateSettingsAndManifests(settings, apps) 82 if expectedErr == nil { 83 Expect(err).ToNot(HaveOccurred()) 84 } else { 85 Expect(err).To(MatchError(expectedErr)) 86 } 87 }, 88 89 Entry("NonexistentAppPathError", 90 CommandLineSettings{ 91 Name: "some-name", 92 ProvidedAppPath: "C:\\does-not-exist", 93 }, nil, 94 actionerror.NonexistentAppPathError{Path: "C:\\does-not-exist"}), 95 96 Entry("NonexistentAppPathError", 97 CommandLineSettings{}, 98 []manifest.Application{{ 99 Name: "some-name", 100 Path: "C:\\does-not-exist", 101 }}, 102 actionerror.NonexistentAppPathError{Path: "C:\\does-not-exist"}), 103 104 Entry("no NonexistentAppPathError if docker image provided via command line", 105 CommandLineSettings{ 106 Name: "some-name", 107 DockerImage: "some-docker-image", 108 }, nil, nil), 109 110 Entry("no NonexistentAppPathError if docker image provided via manifest", 111 CommandLineSettings{}, 112 []manifest.Application{{ 113 Name: "some-name", 114 DockerImage: "some-docker-image", 115 }}, nil), 116 117 Entry("no NonexistentAppPathError if droplet path provided via command line", 118 CommandLineSettings{ 119 Name: "some-name", 120 DropletPath: "some-droplet-path", 121 }, nil, nil), 122 ) 123 124 })