From 5a5aa6009fdfde0524bc4e551742c366ad0164df Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 11 Sep 2021 20:26:28 +0200 Subject: Improve TestAuthConfigsToAuthFile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the created temporary file. Use more appropriate assertion calls. Signed-off-by: Miloslav Trmač --- pkg/auth/auth_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index a0b97b106..38f82ee04 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "io/ioutil" "net/http" + "os" "testing" "github.com/containers/image/v5/types" @@ -57,13 +58,14 @@ func TestAuthConfigsToAuthFile(t *testing.T) { filePath, err := authConfigsToAuthFile(configs) if tc.shouldErr { - assert.NotNil(t, err) + assert.Error(t, err) assert.Empty(t, filePath) } else { - assert.Nil(t, err) + assert.NoError(t, err) content, err := ioutil.ReadFile(filePath) - assert.Nil(t, err) + require.NoError(t, err) assert.Contains(t, string(content), tc.expectedContains) + os.Remove(filePath) } } } -- cgit v1.2.3-54-g00ecf