summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2021-09-11 20:26:28 +0200
committerMiloslav Trmač <mitr@redhat.com>2021-12-10 18:09:55 +0100
commit5a5aa6009fdfde0524bc4e551742c366ad0164df (patch)
treed5f04f9515a8e8d920b5aa0beb1616556582bf62
parentff003928b2360304f6b9458d324df090917fab02 (diff)
downloadpodman-5a5aa6009fdfde0524bc4e551742c366ad0164df.tar.gz
podman-5a5aa6009fdfde0524bc4e551742c366ad0164df.tar.bz2
podman-5a5aa6009fdfde0524bc4e551742c366ad0164df.zip
Improve TestAuthConfigsToAuthFile
Remove the created temporary file. Use more appropriate assertion calls. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-rw-r--r--pkg/auth/auth_test.go8
1 files changed, 5 insertions, 3 deletions
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)
}
}
}