Skip to content

Commit 4b922f6

Browse files
authored
Passing a non-nil context to AuthConfig during testing; Replacing Print+Exit calls with log.Fatal() (#13)
1 parent 8598293 commit 4b922f6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

auth/auth_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func TestMain(m *testing.M) {
103103
}
104104

105105
client, err = NewClient(&internal.AuthConfig{
106+
Ctx: context.Background(),
106107
Creds: creds,
107108
ProjectID: "mock-project-id",
108109
})
@@ -164,7 +165,7 @@ func TestCustomTokenError(t *testing.T) {
164165
}
165166

166167
func TestCustomTokenInvalidCredential(t *testing.T) {
167-
s, err := NewClient(&internal.AuthConfig{})
168+
s, err := NewClient(&internal.AuthConfig{Ctx: context.Background()})
168169
if err != nil {
169170
t.Fatal(err)
170171
}
@@ -227,7 +228,7 @@ func TestVerifyIDTokenError(t *testing.T) {
227228
}
228229

229230
func TestNoProjectID(t *testing.T) {
230-
c, err := NewClient(&internal.AuthConfig{Creds: creds})
231+
c, err := NewClient(&internal.AuthConfig{Ctx: context.Background(), Creds: creds})
231232
if err != nil {
232233
t.Fatal(err)
233234
}

integration/auth_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"flag"
2121
"fmt"
2222
"io/ioutil"
23+
"log"
2324
"net/http"
2425
"os"
2526
"testing"
@@ -37,18 +38,18 @@ var client *auth.Client
3738
func TestMain(m *testing.M) {
3839
flag.Parse()
3940
if testing.Short() {
40-
fmt.Println("skipping auth integration tests in short mode.")
41+
log.Println("skipping auth integration tests in short mode.")
4142
os.Exit(0)
4243
}
4344

4445
app, err := internal.NewTestApp(context.Background())
4546
if err != nil {
46-
os.Exit(1)
47+
log.Fatalln(err)
4748
}
4849

4950
client, err = app.Auth()
5051
if err != nil {
51-
os.Exit(1)
52+
log.Fatalln(err)
5253
}
5354

5455
os.Exit(m.Run())

0 commit comments

Comments
 (0)