github.com/loafoe/cli@v7.1.0+incompatible/integration/shared/plugin/uninstall_plugin_command_unix_test.go (about)

     1  // +build !windows
     2  
     3  package plugin
     4  
     5  import (
     6  	"os"
     7  	"path/filepath"
     8  
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  	"code.cloudfoundry.org/cli/util/generic"
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("uninstall-plugin command", func() {
    18  	When("the plugin is not executable", func() {
    19  		var binaryPath string
    20  
    21  		BeforeEach(func() {
    22  			helpers.InstallConfigurablePlugin("configurable_plugin", "banana-plugin-name-1", "2.0.1", []helpers.PluginCommand{
    23  				{Name: "banana-command-1", Help: "banana-command-1"},
    24  			})
    25  
    26  			binaryPath = generic.ExecutableFilename(
    27  				filepath.Join(homeDir, ".cf", "plugins", "banana-plugin-name-1"))
    28  			Expect(os.Chmod(binaryPath, 0644)).ToNot(HaveOccurred())
    29  		})
    30  
    31  		It("exits with an error, and does not remove the plugin", func() {
    32  			session := helpers.CF("uninstall-plugin", "banana-plugin-name-1")
    33  			Eventually(session).Should(Say(`Uninstalling plugin banana-plugin-name-1\.\.\.`))
    34  			Eventually(session).Should(Say("FAILED"))
    35  			Eventually(session.Err).Should(Say(`The plugin's uninstall method returned an unexpected error\.`))
    36  			Eventually(session.Err).Should(Say(`The plugin uninstall will proceed\. Contact the plugin author if you need help\.`))
    37  			Eventually(session).Should(Exit(1))
    38  
    39  			_, err := os.Stat(binaryPath)
    40  			Expect(os.IsNotExist(err)).To(BeTrue())
    41  
    42  			session = helpers.CF("plugins")
    43  			Consistently(session).ShouldNot(Say("banana-plugin-name-1"))
    44  			Eventually(session).Should(Exit(0))
    45  		})
    46  	})
    47  })