From 5e41ced9ddfa4389e1572a31606b0e14b62140b4 Mon Sep 17 00:00:00 2001 From: Patrick Jones Date: Mon, 11 Jan 2021 13:03:20 -0800 Subject: [PATCH] Changed some test formatting. Change-Id: Ia1f314ae5edd33bc91b5e950c6499c049219ee79 --- .../externalaccount/basecredentials_test.go | 6 +++--- .../externalaccount/filecredsource_test.go | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/google/internal/externalaccount/basecredentials_test.go b/google/internal/externalaccount/basecredentials_test.go index 823fce9..b7c143f 100644 --- a/google/internal/externalaccount/basecredentials_test.go +++ b/google/internal/externalaccount/basecredentials_test.go @@ -43,15 +43,15 @@ func TestToken_Func(t *testing.T) { targetServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if got, want := r.URL.String(), "/"; got != want { - t.Errorf("Unexpected request URL: got %v but want %v", got, want) + t.Errorf("URL.String(): got %v but want %v", got, want) } headerAuth := r.Header.Get("Authorization") if got, want := headerAuth, "Basic cmJyZ25vZ25yaG9uZ28zYmk0Z2I5Z2hnOWc6bm90c29zZWNyZXQ="; got != want { - t.Errorf("Unexpected autohrization header: got %v but want %v", got, want) + t.Errorf("got %v but want %v", got, want) } headerContentType := r.Header.Get("Content-Type") if got, want := headerContentType, "application/x-www-form-urlencoded"; got != want { - t.Errorf("Unexpected Content-Type header: got %v but want %v", got, want) + t.Errorf("got %v but want %v", got, want) } body, err := ioutil.ReadAll(r.Body) if err != nil { diff --git a/google/internal/externalaccount/filecredsource_test.go b/google/internal/externalaccount/filecredsource_test.go index 0ed5ac1..0bc8048 100644 --- a/google/internal/externalaccount/filecredsource_test.go +++ b/google/internal/externalaccount/filecredsource_test.go @@ -50,15 +50,18 @@ func TestRetrieveFileSubjectToken(t *testing.T) { } for _, test := range fileSourceTests { + test := test tfc := testFileConfig tfc.CredentialSource = test.cs - out, err := tfc.parse().subjectToken() - if err != nil { - t.Fatalf("Method retrieveSubjectToken for type fileCredentialSource in test %v failed; %e", test.name, err) - } - if out != test.want { - t.Errorf("Test %v for method retrieveSubjectToken for type fileCredentialSouce failed: expected %v but got %v", test.name, test.want, out) - } + t.Run(test.name, func(t *testing.T) { + out, err := tfc.parse().subjectToken() + if err != nil { + t.Errorf("Method subjectToken() errored.") + } else if test.want != out { + t.Errorf("got %v but want %v", out, test.want) + } + + }) } }