github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/integration/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  	"github.com/liamawhite/cli-with-i18n/integration/helpers"
    10  	"github.com/liamawhite/cli-with-i18n/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  	Context("when the plugin is not executable", func() {
    19  		var binaryPath string
    20  
    21  		BeforeEach(func() {
    22  			helpers.InstallConfigurablePlugin("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.Out).Should(Say("Uninstalling plugin banana-plugin-name-1\\.\\.\\."))
    34  			Eventually(session.Out).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.Out).ShouldNot(Say("banana-plugin-name-1"))
    44  			Eventually(session).Should(Exit(0))
    45  		})
    46  	})
    47  })