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