Improve TestAuthConfigsToAuthFile

Remove the created temporary file.

Use more appropriate assertion calls.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač committed 2021-12-10 18:09:55 +01:00
1 parent ff003928b2
commit 5a5aa6009f
1 file changed
+5 -3
+5 -3
View File
@@ -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)
}
}
}