Skip to content

Commit c65d01b

Browse files
feat(*): update to use new errors from CLI (#239)
1 parent 692b000 commit c65d01b

10 files changed

Lines changed: 71 additions & 25 deletions

File tree

glide.lock

Lines changed: 28 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ import:
55
subpackages:
66
- gbytes
77
- gexec
8+
- package: github.com/deis/controller-sdk-go

tests/apps_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"os"
55
"strings"
66

7+
deis "github.com/deis/controller-sdk-go"
78
"github.com/deis/workflow-e2e/tests/cmd"
89
"github.com/deis/workflow-e2e/tests/cmd/apps"
910
"github.com/deis/workflow-e2e/tests/cmd/auth"
1011
"github.com/deis/workflow-e2e/tests/cmd/builds"
1112
"github.com/deis/workflow-e2e/tests/model"
1213
"github.com/deis/workflow-e2e/tests/settings"
14+
"github.com/deis/workflow-e2e/tests/util"
1315

1416
. "github.com/onsi/ginkgo"
1517
. "github.com/onsi/gomega"
@@ -51,7 +53,7 @@ var _ = Describe("deis apps", func() {
5153

5254
Specify("that user cannot get information about that app", func() {
5355
sess, err := cmd.Start("deis info -a %s", &user, bogusAppName)
54-
Eventually(sess.Err).Should(Say("Not found."))
56+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
5557
Expect(err).NotTo(HaveOccurred())
5658
Eventually(sess).Should(Exit(1))
5759
})
@@ -65,15 +67,15 @@ var _ = Describe("deis apps", func() {
6567

6668
Specify("that user cannot open that app", func() {
6769
sess, err := cmd.Start("deis open -a %s", &user, bogusAppName)
68-
Eventually(sess.Err).Should(Say("404 Not Found"))
70+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
6971
Expect(err).NotTo(HaveOccurred())
7072
Eventually(sess).Should(Exit(1))
7173
})
7274

7375
Specify("that user cannot run a command in that app's environment", func() {
7476
sess, err := cmd.Start("deis apps:run -a %s echo Hello, 世界", &user, bogusAppName)
7577
Eventually(sess).Should(Say("Running 'echo Hello, 世界'..."))
76-
Eventually(sess.Err).Should(Say("Not found."))
78+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
7779
Expect(err).NotTo(HaveOccurred())
7880
Eventually(sess).ShouldNot(Exit(0))
7981
})
@@ -116,7 +118,7 @@ var _ = Describe("deis apps", func() {
116118
Expect(err).NotTo(HaveOccurred())
117119
Eventually(sess).Should(Exit(0))
118120
sess, err = cmd.Start("deis info -a %s", &user, app.Name)
119-
Eventually(sess.Err).Should(Say("You do not have permission to perform this action."))
121+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrForbidden)))
120122
Expect(err).NotTo(HaveOccurred())
121123
Eventually(sess).Should(Exit(1))
122124
// Transer back or else cleanup will fail.

tests/builds_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package tests
22

33
import (
4+
deis "github.com/deis/controller-sdk-go"
45
"github.com/deis/workflow-e2e/tests/cmd"
56
"github.com/deis/workflow-e2e/tests/cmd/apps"
67
"github.com/deis/workflow-e2e/tests/cmd/auth"
78
"github.com/deis/workflow-e2e/tests/cmd/builds"
89
"github.com/deis/workflow-e2e/tests/model"
910
"github.com/deis/workflow-e2e/tests/settings"
11+
"github.com/deis/workflow-e2e/tests/util"
1012

1113
. "github.com/onsi/ginkgo"
1214
. "github.com/onsi/gomega"
@@ -36,7 +38,7 @@ var _ = Describe("deis builds", func() {
3638

3739
Specify("that user cannot create a build for that app", func() {
3840
sess, err := cmd.Start("deis builds:create -a %s %s", &user, bogusAppName, builds.ExampleImage)
39-
Eventually(sess.Err).Should(Say("404 Not Found"))
41+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
4042
Expect(err).NotTo(HaveOccurred())
4143
Eventually(sess).Should(Exit(1))
4244
})

tests/certs_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import (
44
"fmt"
55
"net/http"
66
"strconv"
7+
"strings"
78

9+
deis "github.com/deis/controller-sdk-go"
810
"github.com/deis/workflow-e2e/tests/cmd"
911
"github.com/deis/workflow-e2e/tests/cmd/apps"
1012
"github.com/deis/workflow-e2e/tests/cmd/auth"
1113
"github.com/deis/workflow-e2e/tests/cmd/builds"
1214
"github.com/deis/workflow-e2e/tests/cmd/certs"
1315
"github.com/deis/workflow-e2e/tests/cmd/domains"
1416
"github.com/deis/workflow-e2e/tests/model"
17+
"github.com/deis/workflow-e2e/tests/util"
1518

1619
. "github.com/onsi/ginkgo"
1720
. "github.com/onsi/gomega"
@@ -43,7 +46,9 @@ var _ = Describe("deis certs", func() {
4346

4447
Specify("that user cannot add a cert with a malformed name", func() {
4548
sess, err := cmd.Start("deis certs:add %s %s %s", &user, "bogus.cert.name", cert.CertPath, cert.KeyPath)
46-
Eventually(sess.Err).Should(Say("400 Bad Request"))
49+
// TODO: Figure out spacing issues that necessitate this workaround.
50+
output := sess.Wait().Err.Contents()
51+
Expect(strings.TrimSpace(string(output))).To(Equal(util.PrependError(deis.ErrInvalidName)))
4752
Expect(err).NotTo(HaveOccurred())
4853
Eventually(sess).Should(Exit(1))
4954
})
@@ -66,21 +71,21 @@ var _ = Describe("deis certs", func() {
6671

6772
Specify("that user cannot add a cert with the key and cert files swapped", func() {
6873
sess, err := cmd.Start("deis certs:add %s %s %s", &user, cert.Name, cert.KeyPath, cert.CertPath)
69-
Eventually(sess.Err).Should(Say("400 Bad Request"))
74+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrInvalidCertificate)))
7075
Expect(err).NotTo(HaveOccurred())
7176
Eventually(sess).Should(Exit(1))
7277
})
7378

7479
Specify("that user cannot get info on a non-existent cert", func() {
7580
sess, err := cmd.Start("deis certs:info %s", &user, nonExistentCertName)
76-
Eventually(sess.Err).Should(Say("404 Not Found"))
81+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
7782
Expect(err).NotTo(HaveOccurred())
7883
Eventually(sess).Should(Exit(1))
7984
})
8085

8186
Specify("that user cannot remove a non-existent cert", func() {
8287
sess, err := cmd.Start("deis certs:remove %s", &user, nonExistentCertName)
83-
Eventually(sess.Err).Should(Say("404 Not Found"))
88+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
8489
Expect(err).NotTo(HaveOccurred())
8590
Eventually(sess).Should(Exit(1))
8691
})
@@ -112,14 +117,14 @@ var _ = Describe("deis certs", func() {
112117

113118
Specify("that user cannot attach a non-existent cert to that domain", func() {
114119
sess, err := cmd.Start("deis certs:attach %s %s", &user, nonExistentCertName, domain)
115-
Eventually(sess.Err).Should(Say("404 Not Found"))
120+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
116121
Expect(err).NotTo(HaveOccurred())
117122
Eventually(sess).Should(Exit(1))
118123
})
119124

120125
Specify("that user cannot detatch a non-existent cert from that domain", func() {
121126
sess, err := cmd.Start("deis certs:detach %s %s", &user, nonExistentCertName, domain)
122-
Eventually(sess.Err).Should(Say("404 Not Found"))
127+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
123128
Expect(err).NotTo(HaveOccurred())
124129
Eventually(sess).Should(Exit(1))
125130
})
@@ -142,14 +147,14 @@ var _ = Describe("deis certs", func() {
142147

143148
Specify("that user cannot attach a cert to a non-existent domain", func() {
144149
sess, err := cmd.Start("deis certs:attach %s %s", &user, cert.Name, nonExistentDomain)
145-
Eventually(sess.Err).Should(Say("404 Not Found"))
150+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
146151
Expect(err).NotTo(HaveOccurred())
147152
Eventually(sess).Should(Exit(1))
148153
})
149154

150155
Specify("that user cannot detach a cert from a non-existent domain", func() {
151156
sess, err := cmd.Start("deis certs:detach %s %s", &user, cert.Name, nonExistentDomain)
152-
Eventually(sess.Err).Should(Say("404 Not Found"))
157+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrNotFound)))
153158
Expect(err).NotTo(HaveOccurred())
154159
Eventually(sess).Should(Exit(1))
155160
})

tests/domains_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import (
66
"net/http"
77
"strconv"
88

9+
deis "github.com/deis/controller-sdk-go"
910
"github.com/deis/workflow-e2e/tests/cmd"
1011
"github.com/deis/workflow-e2e/tests/cmd/apps"
1112
"github.com/deis/workflow-e2e/tests/cmd/auth"
1213
"github.com/deis/workflow-e2e/tests/cmd/builds"
1314
"github.com/deis/workflow-e2e/tests/cmd/domains"
1415
"github.com/deis/workflow-e2e/tests/model"
1516
"github.com/deis/workflow-e2e/tests/settings"
17+
"github.com/deis/workflow-e2e/tests/util"
1618

1719
. "github.com/onsi/ginkgo"
1820
. "github.com/onsi/gomega"
@@ -65,7 +67,7 @@ var _ = Describe("deis domains", func() {
6567

6668
Specify("that user cannot remove a non-existent domain from that app", func() {
6769
sess, err := cmd.Start("deis domains:remove --app=%s %s", &user, app.Name, "non.existent.domain")
68-
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say("404 Not Found"))
70+
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say(util.PrependError(deis.ErrNotFound)))
6971
Expect(err).NotTo(HaveOccurred())
7072
Eventually(sess).Should(Exit(1))
7173
})

tests/perms_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package tests
22

33
import (
4+
deis "github.com/deis/controller-sdk-go"
45
"github.com/deis/workflow-e2e/tests/cmd"
56
"github.com/deis/workflow-e2e/tests/cmd/apps"
67
"github.com/deis/workflow-e2e/tests/cmd/auth"
78
"github.com/deis/workflow-e2e/tests/cmd/perms"
89
"github.com/deis/workflow-e2e/tests/model"
910
"github.com/deis/workflow-e2e/tests/settings"
11+
"github.com/deis/workflow-e2e/tests/util"
1012

1113
. "github.com/onsi/ginkgo"
1214
. "github.com/onsi/gomega"
@@ -174,15 +176,15 @@ var _ = Describe("deis perms", func() {
174176

175177
Specify("that user cannot list admin permissions", func() {
176178
sess, err := cmd.Start("deis perms:list --admin", &user)
177-
Eventually(sess.Err).Should(Say("403 Forbidden"))
179+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrForbidden)))
178180
Expect(err).NotTo(HaveOccurred())
179181
Eventually(sess).Should(Exit(1))
180182
})
181183

182184
Specify("that user cannot create admin permissions", func() {
183185
sess, err := cmd.Start("deis perms:create %s --admin", &user, user.Username)
184186
Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("Adding %s to system administrators...", user.Username))
185-
Eventually(sess.Err).Should(Say("403 Forbidden"))
187+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrForbidden)))
186188
Expect(err).NotTo(HaveOccurred())
187189
Eventually(sess).Should(Exit(1))
188190
})
@@ -193,7 +195,7 @@ var _ = Describe("deis perms", func() {
193195

194196
Specify("the non-admin user cannot delete the admin's admin permissions", func() {
195197
sess, err := cmd.Start("deis perms:delete %s --admin", &user, admin.Username)
196-
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say("403 Forbidden"))
198+
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say(util.PrependError(deis.ErrForbidden)))
197199
Expect(err).NotTo(HaveOccurred())
198200
Eventually(sess).Should(Exit(1))
199201
})

tests/tags_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"regexp"
55
"strings"
66

7+
deis "github.com/deis/controller-sdk-go"
78
"github.com/deis/workflow-e2e/tests/cmd"
89
"github.com/deis/workflow-e2e/tests/cmd/apps"
910
"github.com/deis/workflow-e2e/tests/cmd/auth"
1011
"github.com/deis/workflow-e2e/tests/cmd/builds"
1112
"github.com/deis/workflow-e2e/tests/model"
1213
"github.com/deis/workflow-e2e/tests/settings"
14+
"github.com/deis/workflow-e2e/tests/util"
1315

1416
. "github.com/onsi/ginkgo"
1517
. "github.com/onsi/ginkgo/extensions/table"
@@ -56,7 +58,7 @@ var _ = Describe("deis tags", func() {
5658
sess, err := cmd.Start("deis tags:set --app=%s munkafolyamat=yeah", &user, app.Name)
5759
Eventually(sess, settings.MaxEventuallyTimeout).ShouldNot(Say("=== %s Tags", app.Name))
5860
Eventually(sess).ShouldNot(Say(`munkafolyamat\s+yeah`, app.Name))
59-
Eventually(sess.Err).Should(Say("400 Bad Request"))
61+
Eventually(sess.Err).Should(Say(util.PrependError(deis.ErrTagNotFound)))
6062
Expect(err).NotTo(HaveOccurred())
6163
Eventually(sess).Should(Exit(1))
6264
})

tests/users_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package tests
22

33
import (
4+
deis "github.com/deis/controller-sdk-go"
45
"github.com/deis/workflow-e2e/tests/cmd"
56
"github.com/deis/workflow-e2e/tests/cmd/auth"
67
"github.com/deis/workflow-e2e/tests/model"
78
"github.com/deis/workflow-e2e/tests/settings"
9+
"github.com/deis/workflow-e2e/tests/util"
810

911
. "github.com/onsi/ginkgo"
1012
. "github.com/onsi/gomega"
@@ -43,7 +45,7 @@ var _ = Describe("deis users", func() {
4345

4446
Specify("that user cannot list all users", func() {
4547
sess, err := cmd.Start("deis users:list", &user)
46-
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say("403 Forbidden"))
48+
Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say(util.PrependError(deis.ErrForbidden)))
4749
Expect(err).NotTo(HaveOccurred())
4850
Eventually(sess).Should(Exit(1))
4951
})

tests/util/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package util
2+
3+
// PrependError adds 'Error: ' to an expected error, like the CLI does to error messages.
4+
func PrependError(expected error) string {
5+
return "Error: " + expected.Error()
6+
}

0 commit comments

Comments
 (0)