Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Fix lint issues #63

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions hibp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
}
11 changes: 6 additions & 5 deletions pkg/hibp/api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Example() { //nolint:testableexamples
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/hibp/dump/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ 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)
assert.Equal(t, []string{}, scanner.LookupBatch(ctx, []string{"foobar"}))

// 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)
Expand All @@ -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)
Expand Down