github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/integration/helpers/route.go (about)

     1  package helpers
     2  
     3  import (
     4  	"fmt"
     5  
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  type Route struct {
    12  	Space  string
    13  	Host   string
    14  	Domain string
    15  	Path   string
    16  }
    17  
    18  func NewRoute(space string, domain string, hostname string, path string) Route {
    19  	return Route{
    20  		Space:  space,
    21  		Domain: domain,
    22  		Host:   hostname,
    23  		Path:   path,
    24  	}
    25  }
    26  
    27  func (r Route) Create() {
    28  	Eventually(CF("create-route", r.Space, r.Domain, "--hostname", r.Host, "--path", r.Path)).Should(Exit(0))
    29  }
    30  
    31  func (r Route) Delete() {
    32  	Eventually(CF("delete-route", r.Domain, "--hostname", r.Host, "--path", r.Path, "-f")).Should(Exit(0))
    33  }
    34  
    35  func DomainName(prefix ...string) string {
    36  	if len(prefix) > 0 {
    37  		return fmt.Sprintf("integration-%s.com", PrefixedRandomName(prefix[0]))
    38  	}
    39  	return fmt.Sprintf("integration%s.com", PrefixedRandomName(""))
    40  }
    41  
    42  type Domain struct {
    43  	Org  string
    44  	Name string
    45  }
    46  
    47  func NewDomain(org string, name string) Domain {
    48  	return Domain{
    49  		Org:  org,
    50  		Name: name,
    51  	}
    52  }
    53  
    54  func (d Domain) Create() {
    55  	Eventually(CF("create-domain", d.Org, d.Name)).Should(Exit(0))
    56  	Eventually(CF("domains")).Should(And(Exit(0), Say(d.Name)))
    57  }
    58  
    59  func (d Domain) CreateShared() {
    60  	Eventually(CF("create-shared-domain", d.Name)).Should(Exit(0))
    61  }
    62  
    63  func (d Domain) CreateWithRouterGroup(routerGroup string) {
    64  	Eventually(CF("create-shared-domain", d.Name, "--router-group", routerGroup)).Should(Exit(0))
    65  }
    66  
    67  func (d Domain) Share() {
    68  	Eventually(CF("share-private-domain", d.Org, d.Name)).Should(Exit(0))
    69  }
    70  
    71  func (d Domain) Delete() {
    72  	Eventually(CF("delete-domain", d.Name, "-f")).Should(Exit(0))
    73  }