github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v7/isolated/share_private_domain_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"regexp"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gbytes"
    10  	. "github.com/onsi/gomega/gexec"
    11  )
    12  
    13  var _ = Describe("share-private-domain command", func() {
    14  	Context("Help", func() {
    15  		It("displays the help information", func() {
    16  			session := helpers.CF("share-private-domain", "--help")
    17  			Eventually(session).Should(Say("NAME:\n"))
    18  			Eventually(session).Should(Say(regexp.QuoteMeta("share-private-domain - Share a private domain with a specific org")))
    19  			Eventually(session).Should(Say("USAGE:\n"))
    20  			Eventually(session).Should(Say(regexp.QuoteMeta("cf share-private-domain ORG DOMAIN")))
    21  			Eventually(session).Should(Say("SEE ALSO:\n"))
    22  			Eventually(session).Should(Say("create-private-domain, domains, unshare-private-domain"))
    23  			Eventually(session).Should(Exit(0))
    24  		})
    25  	})
    26  
    27  	var (
    28  		sharedWithOrgName string
    29  		orgName           string
    30  		spaceName         string
    31  		domainName        string
    32  	)
    33  
    34  	BeforeEach(func() {
    35  		sharedWithOrgName = helpers.NewOrgName()
    36  		orgName = helpers.NewOrgName()
    37  		spaceName = helpers.NewSpaceName()
    38  		domainName = helpers.NewDomainName()
    39  	})
    40  
    41  	When("user is logged in", func() {
    42  		BeforeEach(func() {
    43  			helpers.SetupCF(orgName, spaceName)
    44  			helpers.CreateOrg(sharedWithOrgName)
    45  			domain := helpers.NewDomain(orgName, domainName)
    46  			domain.CreatePrivate()
    47  		})
    48  
    49  		It("should create the shared domain", func() {
    50  			session := helpers.CF("share-private-domain", sharedWithOrgName, domainName)
    51  
    52  			Eventually(session).Should(Say("Sharing domain %s with org %s as admin...", domainName, sharedWithOrgName))
    53  			Eventually(session).Should(Say("OK"))
    54  			Eventually(session).Should(Exit(0))
    55  
    56  			session = helpers.CF("domains")
    57  			Eventually(session).Should(Say(`%s\s+private`, domainName))
    58  			Eventually(session).Should(Exit(0))
    59  		})
    60  	})
    61  
    62  	When("there is an error", func() {
    63  		It("should report failure and exit with non-zero exit code", func() {
    64  			session := helpers.CF("share-private-domain", orgName, domainName)
    65  
    66  			Eventually(session.Err).Should(Say("Not logged in. Use 'cf login' to log in."))
    67  			Eventually(session).Should(Say("FAILED"))
    68  			Eventually(session).Should(Exit(1))
    69  		})
    70  	})
    71  })