github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/cloudcontroller/minimum_version_check_test.go (about)

     1  package cloudcontroller_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/api/cloudcontroller"
     5  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
     6  
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  )
    10  
    11  var _ = Describe("Minimum Version Check", func() {
    12  	Describe("MinimumAPIVersionCheck", func() {
    13  		minimumVersion := "1.0.0"
    14  		Context("current version is greater than min", func() {
    15  			It("does not return an error", func() {
    16  				currentVersion := "1.0.1"
    17  				err := MinimumAPIVersionCheck(currentVersion, minimumVersion)
    18  				Expect(err).ToNot(HaveOccurred())
    19  			})
    20  		})
    21  
    22  		Context("current version is less than min", func() {
    23  			It("does return an error", func() {
    24  				currentVersion := "1.0.0-alpha.5"
    25  				err := MinimumAPIVersionCheck(currentVersion, minimumVersion)
    26  				Expect(err).To(MatchError(ccerror.MinimumAPIVersionNotMetError{
    27  					CurrentVersion: currentVersion,
    28  					MinimumVersion: minimumVersion,
    29  				}))
    30  			})
    31  		})
    32  
    33  		Context("minimum version is empty", func() {
    34  			It("does not return an error", func() {
    35  				err := MinimumAPIVersionCheck("2.0.0", "")
    36  				Expect(err).ToNot(HaveOccurred())
    37  			})
    38  		})
    39  	})
    40  })