github.com/loafoe/cli@v7.1.0+incompatible/command/v7/shared/version_checker_test.go (about) 1 package shared_test 2 3 import ( 4 "code.cloudfoundry.org/cli/command/v7/shared" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("version checker", func() { 10 var ( 11 warning string 12 executeErr error 13 currentCCVersion string 14 ) 15 16 Context("CheckCCAPIVersion", func() { 17 BeforeEach(func() { 18 currentCCVersion = "3.85.0" 19 }) 20 21 JustBeforeEach(func() { 22 warning, executeErr = shared.CheckCCAPIVersion(currentCCVersion) 23 }) 24 25 It("does not return a warning", func() { 26 Expect(executeErr).ToNot(HaveOccurred()) 27 Expect(warning).To(Equal("")) 28 }) 29 30 When("the current version is less than the minimum version", func() { 31 BeforeEach(func() { 32 currentCCVersion = "3.83.0" 33 }) 34 35 It("does return a warning", func() { 36 Expect(executeErr).ToNot(HaveOccurred()) 37 Expect(warning).To(Equal("\nWarning: Your targeted API's version (3.83.0) is less than the minimum supported API version (3.85.0). Some commands may not function correctly.")) 38 }) 39 }) 40 41 When("the API version is empty", func() { 42 BeforeEach(func() { 43 currentCCVersion = "" 44 }) 45 It("returns an error", func() { 46 Expect(executeErr).To(HaveOccurred()) 47 }) 48 }) 49 50 }) 51 })