github.com/loafoe/cli@v7.1.0+incompatible/integration/shared/plugin/runner_test.go (about) 1 package plugin 2 3 import ( 4 "os" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("running plugins", func() { 14 Describe("panic handling", func() { 15 BeforeEach(func() { 16 Eventually(helpers.CF("install-plugin", "-f", panicTestPluginPath)).Should(Exit(0)) 17 }) 18 19 It("will exit 1 if the plugin panics", func() { 20 Eventually(helpers.CF("freak-out")).Should(Exit(1)) 21 }) 22 }) 23 24 Describe("when running plugin commands while CF_HOME is set", func() { 25 When("CF_PLUGIN_HOME is unset", func() { 26 BeforeEach(func() { 27 Expect(os.Setenv("CF_PLUGIN_HOME", "")).NotTo(HaveOccurred()) 28 }) 29 30 When("a plugin is installed", func() { 31 BeforeEach(func() { 32 installTestPlugin() 33 }) 34 35 AfterEach(func() { 36 uninstallTestPlugin() 37 }) 38 39 It("lists the installed plugins", func() { 40 session := helpers.CF("plugins") 41 Eventually(session).Should(Say("Username")) 42 Eventually(session).Should(Exit(0)) 43 }) 44 45 It("is able to run an installed plugin command", func() { 46 confirmTestPluginOutput("ApiEndpoint", helpers.GetAPI()) 47 }) 48 }) 49 }) 50 51 When("CF_PLUGIN_HOME is set", func() { 52 When("a plugin is installed", func() { 53 BeforeEach(func() { 54 installTestPlugin() 55 }) 56 57 AfterEach(func() { 58 uninstallTestPlugin() 59 }) 60 61 It("lists the installed plugins", func() { 62 session := helpers.CF("plugins") 63 Eventually(session).Should(Say("TestPluginCommandWithAlias")) 64 Eventually(session).Should(Exit(0)) 65 }) 66 67 It("can call a command by its alias", func() { 68 confirmTestPluginOutput("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "You called Test Plugin Command With Alias!") 69 }) 70 }) 71 }) 72 }) 73 })