From 1c444517dc7625b3ecc7c55076147ab743cf8724 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Mon, 3 Jul 2023 18:16:40 -0400 Subject: [PATCH] fix(tests): get rid of loop variables --- pkg/auth/auth_test.go | 3 ++- pkg/generators/statement_generator_test.go | 3 ++- pkg/murmur/murmur_test.go | 6 ++++-- pkg/replication/replication_test.go | 3 ++- pkg/tableopts/options_test.go | 3 ++- pkg/typedef/schema_test.go | 3 ++- pkg/typedef/types_test.go | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 123b45ca..fc722f15 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -59,7 +59,8 @@ func TestSetAuthenticator(t *testing.T) { err: "Username not provided", }, } - for name, test := range tests { + for name := range tests { + test := tests[name] t.Run(name, func(t *testing.T) { t.Parallel() authenticator, err := auth.BuildAuthenticator( diff --git a/pkg/generators/statement_generator_test.go b/pkg/generators/statement_generator_test.go index 6417d7c1..e4bd3a4f 100644 --- a/pkg/generators/statement_generator_test.go +++ b/pkg/generators/statement_generator_test.go @@ -168,7 +168,8 @@ func TestGetCreateSchema(t *testing.T) { }, } - for name, test := range tests { + for name := range tests { + test := tests[name] t.Run(name, func(t *testing.T) { t.Parallel() got := generators.GetCreateTable(test.table, ks) diff --git a/pkg/murmur/murmur_test.go b/pkg/murmur/murmur_test.go index e0a315cf..1180a9c0 100644 --- a/pkg/murmur/murmur_test.go +++ b/pkg/murmur/murmur_test.go @@ -37,7 +37,8 @@ func TestRotl(t *testing.T) { {-6486402271863858009, 31, 405973038345868736}, } - for _, test := range tests { + for id := range tests { + test := tests[id] t.Run(fmt.Sprintf("%d >> %d", test.in, test.rotate), func(t *testing.T) { t.Parallel() if v := rotl(test.in, uint8(test.rotate)); v != test.exp { @@ -59,7 +60,8 @@ func TestFmix(t *testing.T) { {-7566534940689533355, 4729783097411765989}, } - for _, test := range tests { + for id := range tests { + test := tests[id] t.Run(strconv.Itoa(int(test.in)), func(t *testing.T) { t.Parallel() if v := fmix(test.in); v != test.exp { diff --git a/pkg/replication/replication_test.go b/pkg/replication/replication_test.go index a6529921..82ed471c 100644 --- a/pkg/replication/replication_test.go +++ b/pkg/replication/replication_test.go @@ -35,7 +35,8 @@ func TestToCQL(t *testing.T) { want: "{'class':'NetworkTopologyStrategy','datacenter1':1}", }, } - for name, test := range tests { + for name := range tests { + test := tests[name] t.Run(name, func(t *testing.T) { t.Parallel() got := test.rs.ToCQL() diff --git a/pkg/tableopts/options_test.go b/pkg/tableopts/options_test.go index ce089140..38dd011d 100644 --- a/pkg/tableopts/options_test.go +++ b/pkg/tableopts/options_test.go @@ -60,7 +60,8 @@ func TestToCQL(t *testing.T) { "'enabled':true,'max_threshold':32,'min_threshold':4,'tombstone_compaction_interval':86400,'tombstone_threshold':0.2}", }, } - for name, test := range tests { + for name := range tests { + test := tests[name] t.Run(name, func(t *testing.T) { t.Parallel() if o, err := tableopts.FromCQL(test.rs); err != nil { diff --git a/pkg/typedef/schema_test.go b/pkg/typedef/schema_test.go index 1b4b3051..2da47816 100644 --- a/pkg/typedef/schema_test.go +++ b/pkg/typedef/schema_test.go @@ -88,7 +88,8 @@ func TestSchemaConfigValidate(t *testing.T) { }, } cmp.AllowUnexported() - for name, test := range tests { + for name := range tests { + test := tests[name] t.Run(name, func(t *testing.T) { t.Parallel() got := test.config.Valid() diff --git a/pkg/typedef/types_test.go b/pkg/typedef/types_test.go index 08d7465a..32cb9525 100644 --- a/pkg/typedef/types_test.go +++ b/pkg/typedef/types_test.go @@ -215,7 +215,7 @@ var prettytests = []struct { func TestCQLPretty(t *testing.T) { t.Parallel() - + for _, p := range prettytests { result, _ := p.typ.CQLPretty(p.query, p.values) if result != p.expected {