Merge pull request #5835 from thaJeztah/bump_golangci_lint
Dockerfile: update golangci-lint to v1.64.5, replace deprecated `tenv` linter in favor of `usetesting`
This commit is contained in:
@@ -68,19 +68,19 @@ func TestTrustSignerAddErrors(t *testing.T) {
|
||||
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
||||
config.SetDir(t.TempDir())
|
||||
|
||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
||||
tmpDir := t.TempDir()
|
||||
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||
assert.NilError(t, err)
|
||||
tmpfile.Close()
|
||||
defer os.Remove(tmpfile.Name())
|
||||
assert.Check(t, tmpFile.Close())
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
|
||||
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.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) {
|
||||
@@ -130,10 +130,10 @@ func TestIngestPublicKeys(t *testing.T) {
|
||||
}
|
||||
assert.Error(t, err, expectedError)
|
||||
// Call with real file path
|
||||
tmpfile, err := os.CreateTemp("", "pemfile")
|
||||
tmpDir := t.TempDir()
|
||||
tmpFile, err := os.CreateTemp(tmpDir, "pemfile")
|
||||
assert.NilError(t, err)
|
||||
tmpfile.Close()
|
||||
defer os.Remove(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.Check(t, tmpFile.Close())
|
||||
_, 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()))
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,14 +10,14 @@ import (
|
||||
// Enable sets the DEBUG env var to true
|
||||
// and makes the logger to log at debug level.
|
||||
func Enable() {
|
||||
os.Setenv("DEBUG", "1")
|
||||
_ = os.Setenv("DEBUG", "1")
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
// Disable sets the DEBUG env var to false
|
||||
// and makes the logger to log at info level.
|
||||
func Disable() {
|
||||
os.Setenv("DEBUG", "")
|
||||
_ = os.Setenv("DEBUG", "")
|
||||
logrus.SetLevel(logrus.InfoLevel)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
|
||||
func TestEnable(t *testing.T) {
|
||||
defer func() {
|
||||
os.Setenv("DEBUG", "")
|
||||
logrus.SetLevel(logrus.InfoLevel)
|
||||
}()
|
||||
t.Setenv("DEBUG", "")
|
||||
Enable()
|
||||
if os.Getenv("DEBUG") != "1" {
|
||||
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG"))
|
||||
@@ -22,6 +22,7 @@ func TestEnable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDisable(t *testing.T) {
|
||||
t.Setenv("DEBUG", "1")
|
||||
Disable()
|
||||
if os.Getenv("DEBUG") != "" {
|
||||
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG"))
|
||||
@@ -32,6 +33,7 @@ func TestDisable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnabled(t *testing.T) {
|
||||
t.Setenv("DEBUG", "")
|
||||
Enable()
|
||||
if !IsEnabled() {
|
||||
t.Fatal("expected debug enabled, got false")
|
||||
|
||||
Reference in New Issue
Block a user