github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/command/translatableerror/minimum_cf_api_version_not_met_error_test.go (about)

     1  package translatableerror_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/command/translatableerror"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("MinimumAPIVersionNotMetError", func() {
    11  	Describe("Error", func() {
    12  		When("the Command field is not empty and CurrentVersion is not empty", func() {
    13  			It("returns a template with the values of the Command and CurrentVersion fields", func() {
    14  				err := MinimumCFAPIVersionNotMetError{
    15  					Command:        "--some-flag",
    16  					CurrentVersion: "1.2.3",
    17  				}
    18  
    19  				Expect(err.Error()).To(Equal("{{.Command}} requires CF API version {{.MinimumVersion}} or higher. Your target is {{.CurrentVersion}}."))
    20  			})
    21  		})
    22  
    23  		When("the Command field is not empty and CurrentVersion is empty", func() {
    24  			It("returns a template with the value of the Command field", func() {
    25  				err := MinimumCFAPIVersionNotMetError{
    26  					Command: "--some-flag",
    27  				}
    28  
    29  				Expect(err.Error()).To(Equal("{{.Command}} requires CF API version {{.MinimumVersion}} or higher."))
    30  			})
    31  		})
    32  
    33  		When("the Command field is empty and CurrentVersion is not empty", func() {
    34  			It("returns a template with the value of the CurrentVersion field", func() {
    35  				err := MinimumCFAPIVersionNotMetError{
    36  					CurrentVersion: "1.2.3",
    37  				}
    38  
    39  				Expect(err.Error()).To(Equal("This command requires CF API version {{.MinimumVersion}} or higher. Your target is {{.CurrentVersion}}."))
    40  			})
    41  		})
    42  
    43  		When("the Command field is empty and CurrentVersion is empty", func() {
    44  			It("returns a template without Command or CurrentVersion values", func() {
    45  				err := MinimumCFAPIVersionNotMetError{}
    46  
    47  				Expect(err.Error()).To(Equal("This command requires CF API version {{.MinimumVersion}} or higher."))
    48  			})
    49  		})
    50  	})
    51  })