Skip to content

Commit a75d53c

Browse files
committed
golanci-lint: fixes for paralleltest
1 parent 9d0cf41 commit a75d53c

File tree

8 files changed

+21
-13
lines changed

8 files changed

+21
-13
lines changed

api/v1/metric_routes_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func TestGetMetric(t *testing.T) {
120120
})
121121

122122
t.Run("metric", func(t *testing.T) {
123+
t.Parallel()
124+
123125
var envelop metricJSONAPI
124126

125127
assert.NoError(t, json.Unmarshal(rw.Body.Bytes(), &envelop))

internal/js/bundle_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ func TestOpen(t *testing.T) {
760760

761761
for source, b := range map[string]*Bundle{"source": sourceBundle, "archive": arcBundle} {
762762
b := b
763-
t.Run(source, func(t *testing.T) {
763+
t.Run(source, func(t *testing.T) { //nolint:paralleltest
764764
bi, err := b.Instantiate(context.Background(), 0)
765765
require.NoError(t, err)
766766
v, err := bi.getCallableExport(consts.DefaultFn)(sobek.Undefined())
@@ -770,13 +770,13 @@ func TestOpen(t *testing.T) {
770770
}
771771
}
772772

773-
t.Run(tCase.name, testFunc)
773+
t.Run(tCase.name, testFunc) //nolint:paralleltest
774774
if isWindows {
775775
tCase := tCase // copy test case before making modifications
776776
// windowsify the testcase
777777
tCase.openPath = strings.ReplaceAll(tCase.openPath, `/`, `\`)
778778
tCase.pwd = strings.ReplaceAll(tCase.pwd, `/`, `\`)
779-
t.Run(tCase.name+" with windows slash", testFunc)
779+
t.Run(tCase.name+" with windows slash", testFunc) //nolint:paralleltest
780780
}
781781
}
782782
})

internal/js/modules/k6/crypto/crypto_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func TestHexEncode(t *testing.T) {
509509

510510
for _, tc := range testCases {
511511
tc := tc
512-
t.Run(fmt.Sprintf("%T", tc), func(t *testing.T) {
512+
t.Run(fmt.Sprintf("%T", tc), func(t *testing.T) { //nolint:paralleltest
513513
c := Crypto{}
514514
out, err := c.hexEncode(tc)
515515
require.NoError(t, err)

internal/js/modules/k6/metrics/metrics_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestMetrics(t *testing.T) {
129129
_, err := test.rt.RunString(fmt.Sprintf(`var m = new metrics.%s("my_metric"%s)`, fn, isTimeString))
130130
require.NoError(t, err)
131131

132-
t.Run("ExitInit", func(t *testing.T) {
132+
t.Run("ExitInit", func(t *testing.T) { //nolint:paralleltest
133133
mii.StateField = state
134134
mii.InitEnvField = nil
135135
_, err := test.rt.RunString(fmt.Sprintf(`new metrics.%s("my_metric")`, fn))
@@ -147,13 +147,13 @@ func TestMetrics(t *testing.T) {
147147
for _, isThrow := range []bool{false, true} {
148148
state.Options.Throw.Bool = isThrow
149149
test.isThrow = isThrow
150-
t.Run(fmt.Sprintf("%s/isThrow=%v/Simple", name, isThrow), func(t *testing.T) {
150+
t.Run(fmt.Sprintf("%s/isThrow=%v/Simple", name, isThrow), func(t *testing.T) { //nolint:paralleltest
151151
test.js = fmt.Sprintf(`m.add(%v)`, val.JS)
152152
test.expectedTags = map[string]string{"key": "value"}
153153
test.run(t)
154154
})
155155
if !val.noTags {
156-
t.Run(fmt.Sprintf("%s/isThrow=%v/Tags", name, isThrow), func(t *testing.T) {
156+
t.Run(fmt.Sprintf("%s/isThrow=%v/Tags", name, isThrow), func(t *testing.T) { //nolint:paralleltest
157157
test.js = fmt.Sprintf(`m.add(%v, {a:1})`, val.JS)
158158
test.expectedTags = map[string]string{"key": "value", "a": "1"}
159159
test.run(t)

internal/js/runner_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestRunnerNew(t *testing.T) {
7474
assert.Equal(t, int64(0), vuc.getExported("counter").Export())
7575

7676
vu := initVU.Activate(&lib.VUActivationParams{RunContext: ctx})
77-
t.Run("RunOnce", func(t *testing.T) {
77+
t.Run("RunOnce", func(t *testing.T) { //nolint:paralleltest
7878
err = vu.RunOnce()
7979
require.NoError(t, err)
8080
assert.Equal(t, int64(1), vuc.getExported("counter").Export())
@@ -535,7 +535,9 @@ func TestRunnerIntegrationImports(t *testing.T) {
535535
for _, mod := range modules {
536536
mod := mod
537537
t.Run(mod, func(t *testing.T) {
538+
t.Parallel()
538539
t.Run("Source", func(t *testing.T) {
540+
t.Parallel()
539541
_, err := getSimpleRunner(t, "/script.js",
540542
fmt.Sprintf(`import "%s"; export default function() {}`, mod), rtOpts)
541543
require.NoError(t, err)
@@ -575,6 +577,7 @@ func TestRunnerIntegrationImports(t *testing.T) {
575577
for name, r := range testdata {
576578
r := r
577579
t.Run(name, func(t *testing.T) {
580+
t.Parallel()
578581
ctx, cancel := context.WithCancel(context.Background())
579582
defer cancel()
580583
initVU, err := r.NewVU(ctx, 1, 1, make(chan metrics.SampleContainer, 100))

internal/loader/loader_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ func TestLoad(t *testing.T) {
251251
{"HOST", "https://some-path-that-doesnt-exist.js"},
252252
}
253253

254-
filesystems := map[string]fsext.Fs{"https": fsext.NewMemMapFs()}
255254
for _, data := range testData {
256255
moduleSpecifier := data.moduleSpecifier
257256
t.Run(data.name, func(t *testing.T) {
257+
filesystems := map[string]fsext.Fs{"https": fsext.NewMemMapFs()}
258+
t.Parallel()
258259
moduleSpecifierURL, err := loader.Resolve(root, moduleSpecifier)
259260
require.NoError(t, err)
260261

lib/options_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ func TestOptions(t *testing.T) {
372372
}
373373
for _, tc := range tests {
374374
t.Run(tc.name, func(t *testing.T) {
375+
t.Parallel()
375376
tlsAuth := []*TLSAuth{
376377
{TLSAuthFields{
377378
Domains: domains,
@@ -384,6 +385,7 @@ func TestOptions(t *testing.T) {
384385
assert.Equal(t, tlsAuth, opts.TLSAuth)
385386

386387
t.Run("Roundtrip", func(t *testing.T) {
388+
t.Parallel()
387389
optsData, err := json.Marshal(opts)
388390
assert.NoError(t, err)
389391

metrics/thresholds_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func TestThresholdRun(t *testing.T) {
192192
threshold := newThreshold(`rate<0.01`, false, types.NullDuration{})
193193
threshold.parsed = parsed
194194

195-
t.Run("no taint", func(t *testing.T) {
195+
t.Run("no taint", func(t *testing.T) { //nolint:paralleltest
196196
b, err := threshold.runNoTaint(sinks)
197197
assert.NoError(t, err)
198198
assert.True(t, b)
@@ -218,14 +218,14 @@ func TestThresholdRun(t *testing.T) {
218218
threshold := newThreshold(`rate<0.01`, false, types.NullDuration{})
219219
threshold.parsed = parsed
220220

221-
t.Run("no taint", func(t *testing.T) {
221+
t.Run("no taint", func(t *testing.T) { //nolint:paralleltest
222222
b, err := threshold.runNoTaint(sinks)
223223
assert.NoError(t, err)
224224
assert.False(t, b)
225225
assert.False(t, threshold.LastFailed)
226226
})
227227

228-
t.Run("taint", func(t *testing.T) {
228+
t.Run("taint", func(t *testing.T) { //nolint:paralleltest
229229
b, err := threshold.run(sinks)
230230
assert.NoError(t, err)
231231
assert.False(t, b)
@@ -839,7 +839,7 @@ func TestThresholdsJSON(t *testing.T) {
839839
assert.Equal(t, data.gracePeriod, ts.Thresholds[i].AbortGracePeriod)
840840
}
841841

842-
t.Run("marshal", func(t *testing.T) {
842+
t.Run("marshal", func(t *testing.T) { //nolint:paralleltest
843843
data2, err := MarshalJSONWithoutHTMLEscape(ts)
844844
assert.NoError(t, err)
845845
output := data.JSON

0 commit comments

Comments
 (0)