Commands: []plugin.Command{ plugin.Command{ Name: "fakePluginCmd1", Alias: "fpc1", HelpText: "help text here", UsageDetails: plugin.Usage{ Usage: "Usage for fpc1", Options: map[string]string{ "f": "test flag", }, }, }, }, } config.PluginsReturns(m) }) Context("command is a plugin command name", func() { It("prints the usage help for the command", func() { runCommand("fakePluginCmd1") Eventually(ui.Outputs).Should(ContainSubstrings([]string{"fakePluginCmd1", "help text here"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"ALIAS"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"fpc1"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"USAGE"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"Usage for fpc1"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"OPTIONS"})) Eventually(ui.Outputs).Should(ContainSubstrings([]string{"-f", "test flag"})) }) })
}) }) Context("when the plugin's alias conflicts with other installed plugin", func() { It("fails if it shares a command name", func() { pluginsMap := make(map[string]plugin_config.PluginMetadata) pluginsMap["AliasCollision"] = plugin_config.PluginMetadata{ Location: "location/to/config.exe", Commands: []plugin.Command{ { Name: "conflict-alias", HelpText: "Hi!", }, }, } pluginConfig.PluginsReturns(pluginsMap) runCommand(aliasConflicts, "-f") Expect(ui.Outputs).To(ContainSubstrings( []string{"Alias `conflict-alias` is a command/alias in plugin 'AliasCollision'. You could try uninstalling plugin 'AliasCollision' and then install this plugin in order to invoke the `conflict-alias` command. However, you should first fully understand the impact of uninstalling the existing 'AliasCollision' plugin."}, []string{"FAILED"}, )) }) It("fails if it shares a command alias", func() { pluginsMap := make(map[string]plugin_config.PluginMetadata) pluginsMap["AliasCollision"] = plugin_config.PluginMetadata{ Location: "location/to/alias.exe", Commands: []plugin.Command{ {
config = &testconfig.FakePluginConfiguration{} rpc.DefaultServer = rpc.NewServer() }) runCommand := func(args ...string) bool { return testcmd.RunCliCommand("plugins", args, requirementsFactory, updateCommandDependency, false) } Context("If --checksum flag is provided", func() { It("computes and prints the sha1 checksum of the binary", func() { config.PluginsReturns(map[string]plugin_config.PluginMetadata{ "Test1": plugin_config.PluginMetadata{ Location: "../../../fixtures/plugins/test_1.go", Version: plugin.VersionType{Major: 1, Minor: 2, Build: 3}, Commands: []plugin.Command{ {Name: "test_1_cmd1", HelpText: "help text for test_1_cmd1"}, }, }, }) runCommand("--checksum") Expect(ui.Outputs).To(ContainSubstrings( []string{"Plugin Name", "Version", "sha1", "Command Help"}, )) }) }) It("should fail with usage when provided any arguments", func() { requirementsFactory.LoginSuccess = true