github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/cmd/domains/commands.go (about)

     1  package domains
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/deis/workflow-e2e/tests/cmd"
     8  	"github.com/deis/workflow-e2e/tests/model"
     9  	"github.com/deis/workflow-e2e/tests/settings"
    10  
    11  	. "github.com/onsi/gomega"
    12  	. "github.com/onsi/gomega/gbytes"
    13  	. "github.com/onsi/gomega/gexec"
    14  )
    15  
    16  var ErrNoDomainMatch = errors.New("\"No Domain matches the given query.\"")
    17  
    18  // The functions in this file implement SUCCESS CASES for commonly used `deis domains` subcommands.
    19  // This allows each of these to be re-used easily in multiple contexts.
    20  
    21  // Add executes `deis domains:add` as the specified user to add the specified domain to the
    22  // specified app.
    23  func Add(user model.User, app model.App, domain string) {
    24  	sess, err := cmd.Start("deis domains:add %s --app=%s", &user, domain, app.Name)
    25  	// Explicitly build literal substring since 'domain' may be a wildcard domain ('*.foo.com') and
    26  	// we don't want Gomega interpreting this string as a regexp
    27  	Eventually(sess.Wait().Out.Contents()).Should(ContainSubstring(fmt.Sprintf("Adding %s to %s...", domain, app.Name)))
    28  	Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done"))
    29  	Expect(err).NotTo(HaveOccurred())
    30  	Eventually(sess).Should(Exit(0))
    31  }
    32  
    33  // Remove executes `deis domains:remove` as the specified user to remove the specified domain from
    34  // the specified app.
    35  func Remove(user model.User, app model.App, domain string) {
    36  	sess, err := cmd.Start("deis domains:remove %s --app=%s", &user, domain, app.Name)
    37  	// Explicitly build literal substring since 'domain' may be a wildcard domain ('*.foo.com') and
    38  	// we don't want Gomega interpreting this string as a regexp
    39  	Eventually(sess.Wait().Out.Contents()).Should(ContainSubstring(fmt.Sprintf("Removing %s from %s...", domain, app.Name)))
    40  	Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done"))
    41  	Expect(err).NotTo(HaveOccurred())
    42  	Eventually(sess).Should(Exit(0))
    43  }