From 6e036d8e5e09d31a2da724987095477f2037d7a5 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Mon, 22 Jun 2026 19:28:32 -1000 Subject: [PATCH] chore: modenrize code with go-fix --- ds_test.go | 4 ++-- sqlite/ds_test.go | 31 +++++++++++-------------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ds_test.go b/ds_test.go index 167e867..cbe9499 100644 --- a/ds_test.go +++ b/ds_test.go @@ -524,7 +524,7 @@ func SubtestManyKeysAndQuery(t *testing.T) { var keystrs []string var values [][]byte count := 100 - for i := 0; i < count; i++ { + for i := range count { s := fmt.Sprintf("%dkey%d", i, i) dsk := ds.NewKey(s) keystrs = append(keystrs, dsk.String()) @@ -661,7 +661,7 @@ func TestManyKeysAndQuery(t *testing.T) { var keystrs []string var values [][]byte count := 100 - for i := 0; i < count; i++ { + for i := range count { s := fmt.Sprintf("%dkey%d", i, i) dsk := ds.NewKey(s) keystrs = append(keystrs, dsk.String()) diff --git a/sqlite/ds_test.go b/sqlite/ds_test.go index 217b4ae..ea3e9dc 100644 --- a/sqlite/ds_test.go +++ b/sqlite/ds_test.go @@ -80,8 +80,7 @@ func TestQuery(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() addTestCases(t, d, testcases) @@ -175,8 +174,7 @@ func TestHas(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() addTestCases(t, d, testcases) @@ -203,8 +201,7 @@ func TestNotExistGet(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() addTestCases(t, d, testcases) @@ -234,8 +231,7 @@ func TestDelete(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() addTestCases(t, d, testcases) @@ -265,8 +261,7 @@ func TestGetEmpty(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() err := d.Put(ctx, ds.NewKey("/a"), []byte{}) if err != nil { @@ -287,8 +282,7 @@ func TestBatching(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() b, err := d.Batch(ctx) if err != nil { @@ -446,8 +440,7 @@ func TestNotFounds(t *testing.T) { badk := ds.NewKey("notreal") - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() val, err := d.Get(ctx, badk) if err != ds.ErrNotFound { @@ -490,7 +483,7 @@ func SubtestManyKeysAndQuery(t *testing.T) { var keystrs []string var values [][]byte count := 100 - for i := 0; i < count; i++ { + for i := range count { s := fmt.Sprintf("%dkey%d", i, i) dsk := ds.NewKey(s) keystrs = append(keystrs, dsk.String()) @@ -568,8 +561,7 @@ func TestBasicPutGet(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() k := ds.NewKey("foo") val := []byte("Hello Datastore!") @@ -626,14 +618,13 @@ func TestManyKeysAndQuery(t *testing.T) { d, done := newDS(t) defer done() - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() + ctx := t.Context() var keys []ds.Key var keystrs []string var values [][]byte count := 100 - for i := 0; i < count; i++ { + for i := range count { s := fmt.Sprintf("%dkey%d", i, i) dsk := ds.NewKey(s) keystrs = append(keystrs, dsk.String())