From 4671e00043de6296408a2f8325435acd7af3fe73 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Sun, 26 Nov 2023 11:11:17 +0100 Subject: [PATCH] [chore] Fix lint issues Signed-off-by: Dominik Schulz --- hibp_test.go | 24 ++++++++++++------------ pkg/hibp/api/client_test.go | 11 ++++++----- pkg/hibp/dump/scanner_test.go | 8 ++++---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/hibp_test.go b/hibp_test.go index 9c25967..b81d970 100644 --- a/hibp_test.go +++ b/hibp_test.go @@ -17,7 +17,7 @@ import ( "github.com/gopasspw/gopass/pkg/ctxutil" "github.com/gopasspw/gopass/pkg/gopass/apimock" "github.com/gopasspw/gopass/tests/gptest" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/urfave/cli/v2" ) @@ -54,13 +54,13 @@ func TestHIBPDump(t *testing.T) { Name: "dumps", Usage: "dumps", } - assert.NoError(t, bf.Apply(fs)) - assert.NoError(t, fs.Parse([]string{"--dumps=" + fn})) + require.NoError(t, bf.Apply(fs)) + require.NoError(t, fs.Parse([]string{"--dumps=" + fn})) c = cli.NewContext(app, fs, nil) c.Context = ctx - assert.NoError(t, ioutil.WriteFile(fn, []byte(testHibpSample), 0o644)) - assert.NoError(t, act.CheckDump(c.Context, false, []string{fn})) + require.NoError(t, ioutil.WriteFile(fn, []byte(testHibpSample), 0o644)) + require.NoError(t, act.CheckDump(c.Context, false, []string{fn})) // gzip fn = filepath.Join(dir, "dump.txt.gz") @@ -69,14 +69,14 @@ func TestHIBPDump(t *testing.T) { Name: "dumps", Usage: "dumps", } - assert.NoError(t, bf.Apply(fs)) - assert.NoError(t, fs.Parse([]string{"--dumps=" + fn})) + require.NoError(t, bf.Apply(fs)) + require.NoError(t, fs.Parse([]string{"--dumps=" + fn})) c = cli.NewContext(app, fs, nil) c.Context = ctx - assert.NoError(t, testWriteGZ(fn, []byte(testHibpSample))) - assert.NoError(t, act.CheckDump(c.Context, false, []string{fn})) + require.NoError(t, testWriteGZ(fn, []byte(testHibpSample))) + require.NoError(t, act.CheckDump(c.Context, false, []string{fn})) } func testWriteGZ(fn string, buf []byte) error { @@ -131,9 +131,9 @@ func TestHIBPAPI(t *testing.T) { hibpapi.URL = ts.URL // test with one entry - assert.NoError(t, act.CheckAPI(c.Context, false)) + require.NoError(t, act.CheckAPI(c.Context, false)) // add another one - assert.NoError(t, act.gp.Set(ctx, "baz", &apimock.Secret{Buf: []byte("foobar")})) - assert.Error(t, act.CheckAPI(c.Context, false)) + require.NoError(t, act.gp.Set(ctx, "baz", &apimock.Secret{Buf: []byte("foobar")})) + require.Error(t, act.CheckAPI(c.Context, false)) } diff --git a/pkg/hibp/api/client_test.go b/pkg/hibp/api/client_test.go index 4ba138b..eabf529 100644 --- a/pkg/hibp/api/client_test.go +++ b/pkg/hibp/api/client_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func Example() { //nolint:testableexamples @@ -49,17 +50,17 @@ func TestLookup(t *testing.T) { //nolint:paralleltest // test with one entry count, err := Lookup(matchSum) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, matchCount, count) // add another one count, err = Lookup(sha1sum(noMatch)) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, uint64(0), count) // invalid input count, err = Lookup("") - assert.Error(t, err) + require.Error(t, err) assert.Equal(t, uint64(0), count) } @@ -93,12 +94,12 @@ func TestLookupCR(t *testing.T) { //nolint:paralleltest // test with one entry count, err := Lookup(matchSum) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, matchCount, count) // add another one count, err = Lookup(sha1sum(noMatch)) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, uint64(0), count) } diff --git a/pkg/hibp/dump/scanner_test.go b/pkg/hibp/dump/scanner_test.go index b887f2a..02bf026 100644 --- a/pkg/hibp/dump/scanner_test.go +++ b/pkg/hibp/dump/scanner_test.go @@ -58,11 +58,11 @@ func TestScanner(t *testing.T) { // no hibp dump, no scanner _, err := New() - assert.Error(t, err) + require.Error(t, err) // setup file and env (sorted) fn := filepath.Join(td, "dump.txt") - assert.NoError(t, os.WriteFile(fn, []byte(testHibpSampleSorted), 0o644)) + require.NoError(t, os.WriteFile(fn, []byte(testHibpSampleSorted), 0o644)) scanner, err := New(fn) require.NoError(t, err) @@ -70,7 +70,7 @@ func TestScanner(t *testing.T) { // setup file and env (unsorted) fn = filepath.Join(td, "dump.txt") - assert.NoError(t, os.WriteFile(fn, []byte(testHibpSampleUnsorted), 0o644)) + require.NoError(t, os.WriteFile(fn, []byte(testHibpSampleUnsorted), 0o644)) scanner, err = New(fn) require.NoError(t, err) @@ -79,7 +79,7 @@ func TestScanner(t *testing.T) { // gzip fn = filepath.Join(td, "dump.txt.gz") - assert.NoError(t, testWriteGZ(fn, []byte(testHibpSampleSorted))) + require.NoError(t, testWriteGZ(fn, []byte(testHibpSampleSorted))) scanner, err = New(fn) require.NoError(t, err)