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


Golang FakePluginConfiguration.PluginsReturns方法代碼示例

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


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

示例1:

			})
		})

		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]pluginconfig.PluginMetadata)
				pluginsMap["AliasCollision"] = pluginconfig.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]pluginconfig.PluginMetadata)
				pluginsMap["AliasCollision"] = pluginconfig.PluginMetadata{
					Location: "location/to/alias.exe",
					Commands: []plugin.Command{
						{
開發者ID:yingkitw,項目名稱:cli,代碼行數:31,代碼來源:install_plugin_test.go

示例2:

				Commands: []plugin.Command{
					{
						Name:     "fakePluginCmd1",
						Alias:    "fpc1",
						HelpText: "help text here",
						UsageDetails: plugin.Usage{
							Usage: "Usage for fpc1",
							Options: map[string]string{
								"f": "test flag",
							},
						},
					},
				},
			}

			fakeConfig.PluginsReturns(m)
		})

		Context("command is a plugin command name", func() {
			It("prints the usage help for the command", func() {
				flagContext.Parse("fakePluginCmd1")
				cmd.Execute(flagContext)

				Expect(fakeUI.SayCallCount()).To(Equal(1))
				output, _ := fakeUI.SayArgsForCall(0)
				Expect(output).To(ContainSubstring("fakePluginCmd1"))
				Expect(output).To(ContainSubstring("help text here"))
				Expect(output).To(ContainSubstring("ALIAS"))
				Expect(output).To(ContainSubstring("fpc1"))
				Expect(output).To(ContainSubstring("USAGE"))
				Expect(output).To(ContainSubstring("Usage for fpc1"))
開發者ID:yingkitw,項目名稱:cli,代碼行數:31,代碼來源:help_test.go

示例3:

		config = new(pluginconfigfakes.FakePluginConfiguration)

		rpc.DefaultServer = rpc.NewServer()
	})

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("plugins", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Context("If --checksum flag is provided", func() {
		It("computes and prints the sha1 checksum of the binary", func() {
			config.PluginsReturns(map[string]pluginconfig.PluginMetadata{
				"Test1": {
					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"},
			))
		})
	})

	Context("when arguments are provided", func() {
		var cmd commandregistry.Command
開發者ID:jasonkeene,項目名稱:cli,代碼行數:31,代碼來源:plugins_test.go


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