github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/integration/shared/plugin/uninstall_plugin_command_unix_test.go (about)

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