Пример #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")
						Expect(ui.Outputs()).To(ContainSubstrings([]string{"Looking up 'plugin1' from repository 'repo1'"}))
						Expect(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")

							Expect(ui.Outputs()).To(ContainSubstrings([]string{"Error getting plugin metadata from repo"}))
							Expect(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")

							Expect(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{
					{
						Name:        "plugin1",
						Description: "none1",
					},
				}
				result["repo2"] = []clipr.Plugin{
					{
						Name:        "plugin2",
						Description: "none2",
					},
				}
				fakePluginRepo.GetPluginsReturns(result, []string{})

				err := callRepoPlugins()
				Expect(err).NotTo(HaveOccurred())

				Expect(ui.Outputs()).NotTo(ContainSubstrings([]string{"Logged errors:"}))
				Expect(ui.Outputs()).To(ContainSubstrings([]string{"repo1"}))
				Expect(ui.Outputs()).To(ContainSubstrings([]string{"plugin1"}))
				Expect(ui.Outputs()).To(ContainSubstrings([]string{"repo2"}))
				Expect(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{