@@ -4,6 +4,7 @@ package aws
4
4
5
5
import (
6
6
"context"
7
+ "errors"
7
8
"strings"
8
9
"testing"
9
10
@@ -15,7 +16,14 @@ import (
15
16
var ctx = context .Background ()
16
17
17
18
func TestDeploy (t * testing.T ) {
18
- b := NewByocProvider (ctx , client.GrpcClient {}, "ten ant" ) // no domain
19
+ b , err := NewByocProvider (ctx , client.GrpcClient {}, "ten ant" ) // no domain
20
+ if err != nil {
21
+ var credErr ErrMissingAwsCreds
22
+ if errors .As (err , & credErr ) {
23
+ t .Skip ("skipping test; not authenticated" )
24
+ }
25
+ t .Fatalf ("unexpected error: %v" , err )
26
+ }
19
27
b .ProjectName = "byoc_integration_test"
20
28
21
29
t .Run ("multiple ingress without domain" , func (t * testing.T ) {
@@ -41,17 +49,24 @@ func TestDeploy(t *testing.T) {
41
49
}
42
50
43
51
func TestTail (t * testing.T ) {
44
- b := NewByocProvider (ctx , client.GrpcClient {}, "TestTail" )
52
+ b , err := NewByocProvider (ctx , client.GrpcClient {}, "TestTail" )
53
+ if err != nil {
54
+ var credErr ErrMissingAwsCreds
55
+ if errors .As (err , & credErr ) {
56
+ t .Skip ("skipping test; not authenticated" )
57
+ }
58
+ t .Fatalf ("unexpected error: %v" , err )
59
+ }
45
60
b .ProjectName = "byoc_integration_test"
46
61
b .ProjectDomain = "example.com" // avoid rpc call
47
62
48
63
ss , err := b .Follow (context .Background (), & defangv1.TailRequest {})
49
64
if err != nil {
50
65
// the only acceptable error is "unauthorized"
51
- if connect .CodeOf (err ) ! = connect .CodeUnauthenticated {
52
- t .Fatal ( err )
66
+ if connect .CodeOf (err ) = = connect .CodeUnauthenticated {
67
+ t .Skip ( "skipping test; not authorized" )
53
68
}
54
- t .Skip ( "skipping test; not authorized" )
69
+ t .Fatalf ( "unexpected error: %v" , err )
55
70
}
56
71
defer ss .Close ()
57
72
@@ -69,7 +84,14 @@ func TestTail(t *testing.T) {
69
84
}
70
85
71
86
func TestGetServices (t * testing.T ) {
72
- b := NewByocProvider (ctx , client.GrpcClient {}, "TestGetServices" )
87
+ b , err := NewByocProvider (ctx , client.GrpcClient {}, "TestGetServices" )
88
+ if err != nil {
89
+ var credErr ErrMissingAwsCreds
90
+ if errors .As (err , & credErr ) {
91
+ t .Skip ("skipping test; not authenticated" )
92
+ }
93
+ t .Fatalf ("unexpected error: %v" , err )
94
+ }
73
95
b .ProjectName = "byoc_integration_test"
74
96
75
97
services , err := b .GetServices (context .Background ())
@@ -78,7 +100,7 @@ func TestGetServices(t *testing.T) {
78
100
t .Skip ("skipping test; not authorized" )
79
101
}
80
102
// the only acceptable error is "unauthorized"
81
- t .Fatal ( err )
103
+ t .Fatalf ( "unexpected error: %v" , err )
82
104
}
83
105
84
106
if len (services .Services ) != 0 {
@@ -89,7 +111,14 @@ func TestGetServices(t *testing.T) {
89
111
func TestPutSecret (t * testing.T ) {
90
112
const secretName = "hello"
91
113
92
- b := NewByocProvider (ctx , client.GrpcClient {}, "TestPutSecret" )
114
+ b , err := NewByocProvider (ctx , client.GrpcClient {}, "TestPutSecret" )
115
+ if err != nil {
116
+ var credErr ErrMissingAwsCreds
117
+ if errors .As (err , & credErr ) {
118
+ t .Skip ("skipping test; not authenticated" )
119
+ }
120
+ t .Fatalf ("unexpected error: %v" , err )
121
+ }
93
122
b .ProjectName = "byoc_integration_test"
94
123
95
124
t .Run ("delete non-existent" , func (t * testing.T ) {
@@ -141,7 +170,14 @@ func TestPutSecret(t *testing.T) {
141
170
}
142
171
143
172
func TestListSecrets (t * testing.T ) {
144
- b := NewByocProvider (ctx , client.GrpcClient {}, "TestListSecrets" )
173
+ b , err := NewByocProvider (ctx , client.GrpcClient {}, "TestListSecrets" )
174
+ if err != nil {
175
+ var credErr ErrMissingAwsCreds
176
+ if errors .As (err , & credErr ) {
177
+ t .Skip ("skipping test; not authenticated" )
178
+ }
179
+ t .Fatalf ("unexpected error: %v" , err )
180
+ }
145
181
b .ProjectName = "byoc_integration_test2" // ensure we don't accidentally see the secrets from the other test
146
182
147
183
t .Run ("list" , func (t * testing.T ) {
0 commit comments