示例#1
0
		Describe("install from plugin repository when '-r' provided", func() {
			Context("gets metadata of the plugin from repo", func() {
				Context("when repo is not found in config", func() {
					It("informs user repo is not found", func() {
						runCommand("plugin1", "-r", "repo1", "-f")
						Ω(ui.Outputs).To(ContainSubstrings([]string{"Looking up 'plugin1' from repository 'repo1'"}))
						Ω(ui.Outputs).To(ContainSubstrings([]string{"repo1 not found"}))
					})
				})

				Context("when repo is found in config", func() {
					Context("when repo endpoint returns an error", func() {
						It("informs user about the error", func() {
							config.SetPluginRepo(models.PluginRepo{Name: "repo1", Url: ""})
							fakePluginRepo.GetPluginsReturns(nil, []string{"repo error1"})
							runCommand("plugin1", "-r", "repo1", "-f")

							Ω(ui.Outputs).To(ContainSubstrings([]string{"Error getting plugin metadata from repo"}))
							Ω(ui.Outputs).To(ContainSubstrings([]string{"repo error1"}))
						})
					})

					Context("when plugin metadata is available and desired plugin is not found", func() {
						It("informs user about the error", func() {
							config.SetPluginRepo(models.PluginRepo{Name: "repo1", Url: ""})
							fakePluginRepo.GetPluginsReturns(nil, nil)
							runCommand("plugin1", "-r", "repo1", "-f")

							Ω(ui.Outputs).To(ContainSubstrings([]string{"plugin1 is not available in repo 'repo1'"}))
						})
示例#2
0
	Context("when GetPlugins returns a list of plugin meta data", func() {
		It("lists all plugin data", func() {
			result := make(map[string][]clipr.Plugin)
			result["repo1"] = []clipr.Plugin{
				clipr.Plugin{
					Name:        "plugin1",
					Description: "none1",
				},
			}
			result["repo2"] = []clipr.Plugin{
				clipr.Plugin{
					Name:        "plugin2",
					Description: "none2",
				},
			}
			fakePluginRepo.GetPluginsReturns(result, []string{})

			callRepoPlugins()

			Ω(ui.Outputs).ToNot(ContainSubstrings([]string{"Logged errors:"}))
			Ω(ui.Outputs).To(ContainSubstrings([]string{"repo1"}))
			Ω(ui.Outputs).To(ContainSubstrings([]string{"plugin1"}))
			Ω(ui.Outputs).To(ContainSubstrings([]string{"repo2"}))
			Ω(ui.Outputs).To(ContainSubstrings([]string{"plugin2"}))
		})
	})

	Context("If errors are reported back from GetPlugins()", func() {
		It("informs user about the errors", func() {
			fakePluginRepo.GetPluginsReturns(nil, []string{
				"error from repo1",