Example #1
0
				ts, err = rpcserver.NewTestRPCServer(rpcHandlers)
				Expect(err).NotTo(HaveOccurred())
			})

			JustBeforeEach(func() {
				err = ts.Start()
				Expect(err).NotTo(HaveOccurred())
			})

			AfterEach(func() {
				ts.Stop()
			})

			Context("checking MinCliVersion", func() {
				It("it calls rpc cmd 'IsMinCliVersion' if plugin metadata 'MinCliVersion' is set", func() {
					args := []string{ts.Port(), "0"}
					session, err := Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
					Expect(err).ToNot(HaveOccurred())

					session.Wait()

					Expect(rpcHandlers.IsMinCliVersionCallCount()).To(Equal(1))
				})

				Context("when the min cli version is not met", func() {
					BeforeEach(func() {
						rpcHandlers.IsMinCliVersionStub = func(_ string, result *bool) error {
							*result = false
							return nil
						}
					})
		}
	})

	JustBeforeEach(func() {
		err = ts.Start()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		ts.Stop()
	})

	Describe("list-apps", func() {
		Context("Option flags", func() {
			It("accept --started or --stopped as valid optional flag", func() {
				args := []string{ts.Port(), "list-apps", "--started"}
				session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
				session.Wait()
				Expect(err).NotTo(HaveOccurred())

				args = []string{ts.Port(), "list-apps", "--stopped"}
				session, err = gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
				session.Wait()
				Expect(err).NotTo(HaveOccurred())
			})

			It("raises error when invalid flag is provided", func() {
				args := []string{ts.Port(), "list-apps", "--invalid_flag"}
				session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
				session.Wait()
				Expect(err).NotTo(HaveOccurred())