auth
auth/token_test.go
Additional tests, parallel test execution. Test that deleting a token that isn't in the token store returns an ErrTokenNotFound. Test that adding a token that already exists in the token store returns an ErrTokenAlreadyExists. Add t.Parallel() to make the test run in parallel.
1.1 --- a/token_test.go Sun Sep 07 19:06:17 2014 -0400 1.2 +++ b/token_test.go Sun Sep 07 19:07:48 2014 -0400 1.3 @@ -35,6 +35,7 @@ 1.4 } 1.5 1.6 func TestTokenStoreSuccess(t *testing.T) { 1.7 + t.Parallel() 1.8 token := Token{ 1.9 AccessToken: "access", 1.10 RefreshToken: "refresh", 1.11 @@ -47,7 +48,11 @@ 1.12 for _, store := range tokenStores { 1.13 err := store.SaveToken(token) 1.14 if err != nil { 1.15 - t.Errorf("Error saving token to %T: %s", err) 1.16 + t.Errorf("Error saving token to %T: %s", store, err) 1.17 + } 1.18 + err = store.SaveToken(token) 1.19 + if err != ErrTokenAlreadyExists { 1.20 + t.Errorf("Expected ErrTokenAlreadyExists from %T, got %s", store, err) 1.21 } 1.22 retrievedAccess, err := store.GetToken(token.AccessToken, false) 1.23 if err != nil { 1.24 @@ -95,5 +100,9 @@ 1.25 if len(retrievedProfile) != 0 { 1.26 t.Errorf("Expected list of 0 tokens from %T, got %+v", store, retrievedProfile) 1.27 } 1.28 + err = store.RemoveToken(token.AccessToken) 1.29 + if err != ErrTokenNotFound { 1.30 + t.Errorf("Expected ErrTokenNotFound from %T, got %s", store, err) 1.31 + } 1.32 } 1.33 }