github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/api/cloudcontroller/minimum_version_check_test.go (about)

     1  package cloudcontroller_test
     2  
     3  import (
     4  	"time"
     5  
     6  	. "code.cloudfoundry.org/cli/api/cloudcontroller"
     7  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
     8  
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("Minimum Version Check", func() {
    14  	Describe("MinimumAPIVersionCheck", func() {
    15  		minimumVersion := "1.0.0"
    16  		Context("current version is greater than min", func() {
    17  			It("does not return an error", func() {
    18  				currentVersion := "1.0.1"
    19  				err := MinimumAPIVersionCheck(currentVersion, minimumVersion)
    20  				Expect(err).ToNot(HaveOccurred())
    21  			})
    22  		})
    23  
    24  		Context("current version is less than min", func() {
    25  			It("does return an error", func() {
    26  				currentVersion := "1.0.0-alpha.5"
    27  				err := MinimumAPIVersionCheck(currentVersion, minimumVersion)
    28  				Expect(err).To(MatchError(ccerror.MinimumAPIVersionNotMetError{
    29  					CurrentVersion: currentVersion,
    30  					MinimumVersion: minimumVersion,
    31  				}))
    32  			})
    33  		})
    34  
    35  		Context("minimum version is empty", func() {
    36  			It("does not return an error", func() {
    37  				err := MinimumAPIVersionCheck("2.0.0", "")
    38  				Expect(err).ToNot(HaveOccurred())
    39  			})
    40  		})
    41  	})
    42  
    43  	Describe("Minimum version numbers", func() {
    44  		It("are up to date", func() {
    45  			expirationDate, err := time.Parse(time.RFC3339, "2021-01-01T00:00:00Z")
    46  			Expect(err).ToNot(HaveOccurred())
    47  			Expect(time.Now().Before(expirationDate)).To(BeTrue(), "Check https://github.com/cloudfoundry/cli/wiki/Versioning-Policy#cf-cli-minimum-supported-version and update versions if necessary")
    48  		})
    49  	})
    50  })