Beispiel #1
0
// CheckVersion returns an error if the ver is empty, contains an incorrect value or
// a version number that is not compatible with the version of this repo.
func CheckVersion(ver string) error {
	compat, err := version.Compatible(ver)
	if err != nil {
		return err
	}
	if !compat {
		return fmt.Errorf("version mismatch: using goagen %s to generate code that compiles with goa %s",
			ver, version.String())
	}
	return nil
}
Beispiel #2
0
	Context("with an overridden build number", func() {
		BeforeEach(func() {
			build = "custom"
		})
		It("returns the overridden version", func() {
			Ω(ver).Should(HaveSuffix("." + build))
		})
	})

	Context("checking compatibility", func() {
		var otherVersion string
		var compatible bool
		var compErr error

		JustBeforeEach(func() {
			compatible, compErr = version.Compatible(otherVersion)
		})

		Context("with a version with identical major", func() {
			BeforeEach(func() {
				otherVersion = "v" + strconv.Itoa(version.Major) + ".12.13"
			})
			It("returns true", func() {
				Ω(compErr).ShouldNot(HaveOccurred())
				Ω(compatible).Should(BeTrue())
			})
		})

		Context("with a version with different major", func() {
			BeforeEach(func() {
				otherVersion = "v99999121299999.1.0"