當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakePluginConfiguration.PluginsReturns方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/configuration/plugin_config/fakes.FakePluginConfiguration.PluginsReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePluginConfiguration.PluginsReturns方法的具體用法?Golang FakePluginConfiguration.PluginsReturns怎麽用?Golang FakePluginConfiguration.PluginsReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/cli/cf/configuration/plugin_config/fakes.FakePluginConfiguration的用法示例。


在下文中一共展示了FakePluginConfiguration.PluginsReturns方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

				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"}))
			})
		})
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:help_test.go

示例2:

			})
		})

		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{
						{
開發者ID:emc-xchallenge,項目名稱:cli,代碼行數:31,代碼來源:install_plugin_test.go

示例3:

		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
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:plugins_test.go


注:本文中的github.com/cloudfoundry/cli/cf/configuration/plugin_config/fakes.FakePluginConfiguration.PluginsReturns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。