Skip to content

Commit

Permalink
Fix linting issue and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Apr 26, 2024
1 parent e9aa884 commit 5d61907
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
13 changes: 3 additions & 10 deletions internal/utils/io_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utils

import (
"fmt"
"io"
"os"
"path/filepath"
Expand All @@ -13,7 +12,6 @@ import (
)

func TestReadFile(t *testing.T) {
t.Parallel()
type args struct {
filename string
}
Expand Down Expand Up @@ -44,7 +42,7 @@ func TestReadFile(t *testing.T) {
func setStdinContent(t *testing.T, content string) (cleanup func()) {
f, err := os.CreateTemp("" /* dir */, "utils-read-test")
require.NoError(t, err)
_, err = f.Write([]byte(content))
_, err = f.WriteString(content)
require.NoError(t, err)
_, err = f.Seek(0, io.SeekStart)
require.NoError(t, err)
Expand Down Expand Up @@ -97,7 +95,6 @@ func TestReadFromStdinFails(t *testing.T) {
}

func TestReadPasswordFromFile(t *testing.T) {
t.Parallel()
type args struct {
filename string
}
Expand Down Expand Up @@ -166,9 +163,7 @@ func TestWriteFile(t *testing.T) {
}

func Test_maybeUnwrap(t *testing.T) {
t.Parallel()
wantErr := fmt.Errorf("the error")

wantErr := errors.New("the error")
type args struct {
err error
}
Expand All @@ -183,9 +178,7 @@ func Test_maybeUnwrap(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := maybeUnwrap(tt.args.err)
if !reflect.DeepEqual(err, tt.wantErr) { //nolint:govet // legacy deep equal error check
t.Errorf("maybeUnwrap() error = %v, wantErr %v", err, tt.wantErr)
}
require.Equal(t, tt.wantErr, err)
})
}
}
4 changes: 2 additions & 2 deletions pemutil/pem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func TestReadCertificate(t *testing.T) {
{"testdata/ca.der", nil, nil},
{"testdata/bundle.crt", []Options{WithFirstBlock()}, nil},
{"testdata/bundle.crt", nil, errors.New("error decoding testdata/bundle.crt: contains more than one PEM encoded block")},
{"testdata/notexists.crt", nil, errors.New("error reading testdata/notexists.crt: no such file or directory")},
{"testdata/notexists.crt", nil, errors.New(`error reading "testdata/notexists.crt": no such file or directory`)},
{"testdata/badca.crt", nil, errors.New("error parsing testdata/badca.crt")},
{"testdata/badpem.crt", nil, errors.New("file testdata/badpem.crt does not contain a valid PEM encoded certificate")},
{"testdata/badder.crt", nil, errors.New("error parsing testdata/badder.crt")},
Expand Down Expand Up @@ -376,7 +376,7 @@ func TestReadCertificateBundle(t *testing.T) {
{"testdata/ca.der", 1, nil},
{"testdata/bundle.crt", 2, nil},
{"testdata/extrajunkbundle.crt", 2, nil},
{"testdata/notexists.crt", 0, errors.New("error reading testdata/notexists.crt: no such file or directory")},
{"testdata/notexists.crt", 0, errors.New(`error reading "testdata/notexists.crt": no such file or directory`)},
{"testdata/badca.crt", 0, errors.New("error parsing testdata/badca.crt")},
{"testdata/badpem.crt", 0, errors.New("file testdata/badpem.crt does not contain a valid PEM encoded certificate")},
{"testdata/badder.crt", 0, errors.New("error parsing testdata/badder.crt")},
Expand Down

0 comments on commit 5d61907

Please sign in to comment.