github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/requirements/targeted_organization_test.go (about)

     1  package requirements_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
     5  	"code.cloudfoundry.org/cli/cf/models"
     6  
     7  	testconfig "code.cloudfoundry.org/cli/util/testhelpers/configuration"
     8  
     9  	. "code.cloudfoundry.org/cli/cf/requirements"
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  var _ = Describe("TargetedOrganizationRequirement", func() {
    15  	var (
    16  		config coreconfig.ReadWriter
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		config = testconfig.NewRepositoryWithDefaults()
    21  	})
    22  
    23  	Context("when the user has an org targeted", func() {
    24  		It("succeeds", func() {
    25  			req := NewTargetedOrgRequirement(config)
    26  			err := req.Execute()
    27  			Expect(err).NotTo(HaveOccurred())
    28  		})
    29  	})
    30  
    31  	Context("when the user does not have an org targeted", func() {
    32  		It("errors", func() {
    33  			config.SetOrganizationFields(models.OrganizationFields{})
    34  
    35  			err := NewTargetedOrgRequirement(config).Execute()
    36  
    37  			Expect(err).To(HaveOccurred())
    38  			Expect(err.Error()).To(ContainSubstring("No org targeted"))
    39  		})
    40  	})
    41  })