jwt: fix bad test message style
Change-Id: I84c311778a1ad3e824e65c1e797223f51f0bc2ea
Reviewed-on: https://go-review.googlesource.com/27890
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/jwt/jwt_test.go b/jwt/jwt_test.go
index b79b816..a490af5 100644
--- a/jwt/jwt_test.go
+++ b/jwt/jwt_test.go
@@ -61,20 +61,20 @@
t.Fatal(err)
}
if !tok.Valid() {
- t.Errorf("Token invalid")
+ t.Errorf("got invalid token: %v", tok)
}
- if tok.AccessToken != "90d64460d14870c08c81352a05dedd3465940a7c" {
- t.Errorf("Unexpected access token, %#v", tok.AccessToken)
+ if got, want := tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c"; got != want {
+ t.Errorf("access token = %q; want %q", got, want)
}
- if tok.TokenType != "bearer" {
- t.Errorf("Unexpected token type, %#v", tok.TokenType)
+ if got, want := tok.TokenType, "bearer"; got != want {
+ t.Errorf("token type = %q; want %q", got, want)
}
- if tok.Expiry.IsZero() {
- t.Errorf("Unexpected token expiry, %#v", tok.Expiry)
+ if got := tok.Expiry.IsZero(); got {
+ t.Errorf("token expiry = %v, want none", got)
}
scope := tok.Extra("scope")
- if scope != "user" {
- t.Errorf("Unexpected value for scope: %v", scope)
+ if got, want := scope, "user"; got != want {
+ t.Errorf("scope = %q; want %q", got, want)
}
}
@@ -95,20 +95,20 @@
t.Fatal(err)
}
if tok == nil {
- t.Fatalf("token is nil")
+ t.Fatalf("got nil token; want token")
}
if tok.Valid() {
- t.Errorf("token is valid. want invalid.")
+ t.Errorf("got invalid token: %v", tok)
}
- if tok.AccessToken != "" {
- t.Errorf("Unexpected non-empty access token %q.", tok.AccessToken)
+ if got, want := tok.AccessToken, ""; got != want {
+ t.Errorf("access token = %q; want %q", got, want)
}
- if want := "bearer"; tok.TokenType != want {
- t.Errorf("TokenType = %q; want %q", tok.TokenType, want)
+ if got, want := tok.TokenType, "bearer"; got != want {
+ t.Errorf("token type = %q; want %q", got, want)
}
scope := tok.Extra("scope")
- if want := "user"; scope != want {
- t.Errorf("token scope = %q; want %q", scope, want)
+ if got, want := scope, "user"; got != want {
+ t.Errorf("token scope = %q; want %q", got, want)
}
}
@@ -126,8 +126,8 @@
tok, err := conf.TokenSource(context.Background()).Token()
if err == nil {
t.Error("got a token; expected error")
- if tok.AccessToken != "" {
- t.Errorf("Unexpected access token, %#v.", tok.AccessToken)
+ if got, want := tok.AccessToken, ""; got != want {
+ t.Errorf("access token = %q; want %q", got, want)
}
}
}