cli/command/trust: fix "usetesting" linting errors
cli/command/trust/signer_add_test.go:71:18: os.CreateTemp("", ...) could be replaced by os.CreateTemp(t.TempDir(), ...) in TestSignerAddCommandNoTargetsKey (usetesting) tmpfile, err := os.CreateTemp("", "pemfile") ^ cli/command/trust/signer_add_test.go:133:18: os.CreateTemp("", ...) could be replaced by os.CreateTemp(t.TempDir(), ...) in TestIngestPublicKeys (usetesting) tmpfile, err := os.CreateTemp("", "pemfile") ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b2f3c12497
commit
aca0bd7757
@ -68,19 +68,19 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
|||||||
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
||||||
config.SetDir(t.TempDir())
|
config.SetDir(t.TempDir())
|
||||||
|
|
||||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
tmpDir := t.TempDir()
|
||||||
|
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
tmpfile.Close()
|
assert.Check(t, tmpFile.Close())
|
||||||
defer os.Remove(tmpfile.Name())
|
|
||||||
|
|
||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
||||||
cmd := newSignerAddCommand(cli)
|
cmd := newSignerAddCommand(cli)
|
||||||
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
cmd.SetArgs([]string{"--key", tmpFile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
||||||
|
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetErr(io.Discard)
|
||||||
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpFile.Name()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
||||||
@ -130,10 +130,10 @@ func TestIngestPublicKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.Error(t, err, expectedError)
|
assert.Error(t, err, expectedError)
|
||||||
// Call with real file path
|
// Call with real file path
|
||||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
tmpDir := t.TempDir()
|
||||||
|
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
tmpfile.Close()
|
assert.Check(t, tmpFile.Close())
|
||||||
defer os.Remove(tmpfile.Name())
|
_, err = ingestPublicKeys([]string{tmpFile.Name()})
|
||||||
_, err = ingestPublicKeys([]string{tmpfile.Name()})
|
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpFile.Name()))
|
||||||
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user