コード例 #1
0
ファイル: max_api_version_test.go プロジェクト: Reejoshi/cli
	BeforeEach(func() {
		config = testconfig.NewRepository()
		maximumVersion, err := semver.Make("1.2.3")
		Expect(err).NotTo(HaveOccurred())

		requirement = requirements.NewMaxAPIVersionRequirement(config, "version-restricted-feature", maximumVersion)
	})

	Context("Execute", func() {
		Context("when the config's api version is less than the maximum version", func() {
			BeforeEach(func() {
				config.SetAPIVersion("1.2.2")
			})

			It("succeeds", func() {
				err := requirement.Execute()
				Expect(err).NotTo(HaveOccurred())
			})
		})

		Context("when the config's api version is equal to the maximum version", func() {
			BeforeEach(func() {
				config.SetAPIVersion("1.2.3")
			})

			It("succeeds", func() {
				err := requirement.Execute()
				Expect(err).NotTo(HaveOccurred())
			})
		})
コード例 #2
0
		ui = new(testterm.FakeUI)
		config = testconfig.NewRepository()
		maximumVersion, err := semver.Make("1.2.3")
		Expect(err).NotTo(HaveOccurred())

		requirement = requirements.NewMaxAPIVersionRequirement(ui, config, "version-restricted-feature", maximumVersion)
	})

	Context("Execute", func() {
		Context("when the config's api version is less than the maximum version", func() {
			BeforeEach(func() {
				config.SetApiVersion("1.2.2")
			})

			It("returns true", func() {
				Expect(requirement.Execute()).To(BeTrue())
			})

			It("does not print anything", func() {
				requirement.Execute()
				Expect(ui.Outputs).To(BeEmpty())
			})
		})

		Context("when the config's api version is equal to the maximum version", func() {
			BeforeEach(func() {
				config.SetApiVersion("1.2.3")
			})

			It("returns true", func() {
				Expect(requirement.Execute()).To(BeTrue())