From a95c923d6a5d256fa92629a1fcb908495d7b1338 Mon Sep 17 00:00:00 2001 From: Jin Qin Date: Mon, 11 Mar 2024 22:44:44 +0000 Subject: [PATCH] address nits --- google/externalaccount/basecredentials_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/google/externalaccount/basecredentials_test.go b/google/externalaccount/basecredentials_test.go index 283800e3c..8f165cdb0 100644 --- a/google/externalaccount/basecredentials_test.go +++ b/google/externalaccount/basecredentials_test.go @@ -241,7 +241,10 @@ func TestToken(t *testing.T) { Scopes: []string{"https://www.googleapis.com/auth/devstorage.full_control"}, } - responseBody, _ := json.Marshal(testCase.responseBody) + responseBody, err := json.Marshal(testCase.responseBody) + if err != nil { + t.Errorf("Invalid response received.") + } server := testExchangeTokenServer{ url: "/", @@ -254,10 +257,8 @@ func TestToken(t *testing.T) { tok, err := run(t, &config, &server) - if err != nil { - if err.Error() != testCase.expectErrorMsg { - t.Errorf("Error actual = %v, and Expect = %v", err, testCase.expectErrorMsg) - } + if err != nil && err.Error() != testCase.expectErrorMsg { + t.Errorf("Error not as expected: got = %v, and want = %v", err, testCase.expectErrorMsg) } validateToken(t, tok, testCase.expectToken) }