github.com/goldeneggg/goa@v1.3.1/version/version_test.go (about) 1 package version_test 2 3 import ( 4 "strconv" 5 6 "github.com/goadesign/goa/version" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("version", func() { 12 var ver string 13 14 JustBeforeEach(func() { 15 ver = version.String() 16 }) 17 18 Context("with the default build number", func() { 19 It("should be properly formatted", func() { 20 Ω(ver).Should(HavePrefix("v")) 21 }) 22 }) 23 24 Context("checking compatibility", func() { 25 var otherVersion string 26 var compatible bool 27 var compErr error 28 29 JustBeforeEach(func() { 30 compatible, compErr = version.Compatible(otherVersion) 31 }) 32 33 Context("with a version with identical major", func() { 34 BeforeEach(func() { 35 otherVersion = "v" + strconv.Itoa(version.Major) + ".12.13" 36 }) 37 It("returns true", func() { 38 Ω(compErr).ShouldNot(HaveOccurred()) 39 Ω(compatible).Should(BeTrue()) 40 }) 41 }) 42 43 Context("with a version with different major", func() { 44 BeforeEach(func() { 45 otherVersion = "v99999121299999.1.0" 46 }) 47 It("returns false", func() { 48 Ω(compErr).ShouldNot(HaveOccurred()) 49 Ω(compatible).Should(BeFalse()) 50 }) 51 }) 52 53 Context("with a non version string", func() { 54 BeforeEach(func() { 55 otherVersion = "v99999121299999.2" 56 }) 57 It("returns an error", func() { 58 Ω(compErr).Should(HaveOccurred()) 59 Ω(compatible).Should(BeFalse()) 60 }) 61 }) 62 }) 63 64 })