github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/actor/pluginaction/install_windows_test.go (about) 1 //go:build windows 2 // +build windows 3 4 package pluginaction_test 5 6 import ( 7 "io/ioutil" 8 "os" 9 10 . "code.cloudfoundry.org/cli/actor/pluginaction" 11 "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" 12 . "github.com/onsi/ginkgo" 13 . "github.com/onsi/gomega" 14 ) 15 16 var _ = Describe("install actions", func() { 17 var ( 18 actor *Actor 19 fakeConfig *pluginactionfakes.FakeConfig 20 tempPluginDir string 21 ) 22 23 BeforeEach(func() { 24 fakeConfig = new(pluginactionfakes.FakeConfig) 25 var err error 26 tempPluginDir, err = ioutil.TempDir("", "") 27 Expect(err).ToNot(HaveOccurred()) 28 actor = NewActor(fakeConfig, nil) 29 }) 30 31 AfterEach(func() { 32 err := os.RemoveAll(tempPluginDir) 33 Expect(err).ToNot(HaveOccurred()) 34 }) 35 36 Describe("CreateExecutableCopy", func() { 37 When("the file exists", func() { 38 var pluginPath string 39 40 BeforeEach(func() { 41 tempFile, err := ioutil.TempFile("", "") 42 Expect(err).ToNot(HaveOccurred()) 43 44 _, err = tempFile.WriteString("cthulhu") 45 Expect(err).ToNot(HaveOccurred()) 46 err = tempFile.Close() 47 Expect(err).ToNot(HaveOccurred()) 48 49 pluginPath = tempFile.Name() 50 }) 51 52 AfterEach(func() { 53 err := os.Remove(pluginPath) 54 Expect(err).ToNot(HaveOccurred()) 55 }) 56 57 It("adds .exe to the end of the filename", func() { 58 copyPath, err := actor.CreateExecutableCopy(pluginPath, tempPluginDir) 59 Expect(err).ToNot(HaveOccurred()) 60 61 Expect(copyPath).To(HaveSuffix(".exe")) 62 }) 63 }) 64 }) 65 })