Skip to content

Commit 85b609c

Browse files
committed
Run golangci-lint run --fix
1 parent 71c9fbf commit 85b609c

39 files changed

+104
-102
lines changed

internal/cmd/cloud.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,10 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error {
252252

253253
statusText := testProgress.RunStatusText
254254

255-
if testProgress.RunStatus == cloudapi.RunStatusFinished {
255+
switch testProgress.RunStatus {
256+
case cloudapi.RunStatusFinished:
256257
testProgress.Progress = 1
257-
} else if testProgress.RunStatus == cloudapi.RunStatusRunning {
258+
case cloudapi.RunStatusRunning:
258259
if startTime.IsZero() {
259260
startTime = time.Now()
260261
}

internal/cmd/config_consolidation_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,16 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
332332

333333
// Test system tags
334334
{opts{}, exp{}, func(t *testing.T, c Config) {
335-
assert.Equal(t, &metrics.DefaultSystemTagSet, c.Options.SystemTags)
335+
assert.Equal(t, &metrics.DefaultSystemTagSet, c.SystemTags)
336336
}},
337337
{opts{cli: []string{"--system-tags", `""`}}, exp{}, func(t *testing.T, c Config) {
338-
assert.Equal(t, metrics.SystemTagSet(0), *c.Options.SystemTags)
338+
assert.Equal(t, metrics.SystemTagSet(0), *c.SystemTags)
339339
}},
340340
{opts{env: []string{`K6_SYSTEM_TAGS=""`}}, exp{}, func(t *testing.T, c Config) {
341-
assert.Equal(t, metrics.SystemTagSet(0), *c.Options.SystemTags)
341+
assert.Equal(t, metrics.SystemTagSet(0), *c.SystemTags)
342342
}},
343343
{opts{env: []string{`K6_SYSTEM_TAGS=proto,method`}}, exp{}, func(t *testing.T, c Config) {
344-
assert.Equal(t, metrics.SystemTagSet(metrics.TagProto|metrics.TagMethod), *c.Options.SystemTags)
344+
assert.Equal(t, metrics.SystemTagSet(metrics.TagProto|metrics.TagMethod), *c.SystemTags)
345345
}},
346346
{
347347
opts{
@@ -354,7 +354,7 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
354354
assert.Equal(
355355
t,
356356
*metrics.NewSystemTagSet(metrics.TagSubproto, metrics.TagURL),
357-
*c.Options.SystemTags,
357+
*c.SystemTags,
358358
)
359359
},
360360
},
@@ -374,61 +374,61 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
374374

375375
// Test summary trend stats
376376
{opts{}, exp{}, func(t *testing.T, c Config) {
377-
assert.Equal(t, lib.DefaultSummaryTrendStats, c.Options.SummaryTrendStats)
377+
assert.Equal(t, lib.DefaultSummaryTrendStats, c.SummaryTrendStats)
378378
}},
379379
{opts{cli: []string{"--summary-trend-stats", ""}}, exp{}, func(t *testing.T, c Config) {
380-
assert.Equal(t, []string{}, c.Options.SummaryTrendStats)
380+
assert.Equal(t, []string{}, c.SummaryTrendStats)
381381
}},
382382
{opts{cli: []string{"--summary-trend-stats", "coun"}}, exp{consolidationError: true}, nil},
383383
{opts{cli: []string{"--summary-trend-stats", "med,avg,p("}}, exp{consolidationError: true}, nil},
384384
{opts{cli: []string{"--summary-trend-stats", "med,avg,p(-1)"}}, exp{consolidationError: true}, nil},
385385
{opts{cli: []string{"--summary-trend-stats", "med,avg,p(101)"}}, exp{consolidationError: true}, nil},
386386
{opts{cli: []string{"--summary-trend-stats", "med,avg,p(99.999)"}}, exp{}, func(t *testing.T, c Config) {
387-
assert.Equal(t, []string{"med", "avg", "p(99.999)"}, c.Options.SummaryTrendStats)
387+
assert.Equal(t, []string{"med", "avg", "p(99.999)"}, c.SummaryTrendStats)
388388
}},
389389
{
390390
opts{runner: &lib.Options{SummaryTrendStats: []string{"avg", "p(90)", "count"}}},
391391
exp{},
392392
func(t *testing.T, c Config) {
393-
assert.Equal(t, []string{"avg", "p(90)", "count"}, c.Options.SummaryTrendStats)
393+
assert.Equal(t, []string{"avg", "p(90)", "count"}, c.SummaryTrendStats)
394394
},
395395
},
396396
{opts{cli: []string{}}, exp{}, func(t *testing.T, c Config) {
397397
assert.Equal(t, types.DNSConfig{
398398
TTL: null.NewString("5m", false),
399399
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: false},
400400
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSpreferIPv4, Valid: false},
401-
}, c.Options.DNS)
401+
}, c.DNS)
402402
}},
403403
{opts{env: []string{"K6_DNS=ttl=5,select=roundRobin"}}, exp{}, func(t *testing.T, c Config) {
404404
assert.Equal(t, types.DNSConfig{
405405
TTL: null.StringFrom("5"),
406406
Select: types.NullDNSSelect{DNSSelect: types.DNSroundRobin, Valid: true},
407407
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSpreferIPv4, Valid: false},
408-
}, c.Options.DNS)
408+
}, c.DNS)
409409
}},
410410
{opts{env: []string{"K6_DNS=ttl=inf,select=random,policy=preferIPv6"}}, exp{}, func(t *testing.T, c Config) {
411411
assert.Equal(t, types.DNSConfig{
412412
TTL: null.StringFrom("inf"),
413413
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: true},
414414
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSpreferIPv6, Valid: true},
415-
}, c.Options.DNS)
415+
}, c.DNS)
416416
}},
417417
// This is functionally invalid, but will error out in validation done in js.parseTTL().
418418
{opts{cli: []string{"--dns", "ttl=-1"}}, exp{}, func(t *testing.T, c Config) {
419419
assert.Equal(t, types.DNSConfig{
420420
TTL: null.StringFrom("-1"),
421421
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: false},
422422
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSpreferIPv4, Valid: false},
423-
}, c.Options.DNS)
423+
}, c.DNS)
424424
}},
425425
{opts{cli: []string{"--dns", "ttl=0,blah=nope"}}, exp{cliReadError: true}, nil},
426426
{opts{cli: []string{"--dns", "ttl=0"}}, exp{}, func(t *testing.T, c Config) {
427427
assert.Equal(t, types.DNSConfig{
428428
TTL: null.StringFrom("0"),
429429
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: false},
430430
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSpreferIPv4, Valid: false},
431-
}, c.Options.DNS)
431+
}, c.DNS)
432432
}},
433433
{opts{cli: []string{"--dns", "ttl=5s,select="}}, exp{cliReadError: true}, nil},
434434
{
@@ -439,7 +439,7 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
439439
TTL: null.StringFrom("0"),
440440
Select: types.NullDNSSelect{DNSSelect: types.DNSroundRobin, Valid: true},
441441
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSonlyIPv4, Valid: true},
442-
}, c.Options.DNS)
442+
}, c.DNS)
443443
},
444444
},
445445
{
@@ -453,7 +453,7 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
453453
TTL: null.StringFrom("30"),
454454
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: false},
455455
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSany, Valid: true},
456-
}, c.Options.DNS)
456+
}, c.DNS)
457457
},
458458
},
459459
{
@@ -469,15 +469,15 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
469469
TTL: null.StringFrom("5"),
470470
Select: types.NullDNSSelect{DNSSelect: types.DNSrandom, Valid: true},
471471
Policy: types.NullDNSPolicy{DNSPolicy: types.DNSany, Valid: true},
472-
}, c.Options.DNS)
472+
}, c.DNS)
473473
},
474474
},
475475
{
476476
opts{env: []string{"K6_NO_SETUP=true", "K6_NO_TEARDOWN=false"}},
477477
exp{},
478478
func(t *testing.T, c Config) {
479-
assert.Equal(t, null.BoolFrom(true), c.Options.NoSetup)
480-
assert.Equal(t, null.BoolFrom(false), c.Options.NoTeardown)
479+
assert.Equal(t, null.BoolFrom(true), c.NoSetup)
480+
assert.Equal(t, null.BoolFrom(false), c.NoTeardown)
481481
},
482482
},
483483
{
@@ -509,7 +509,7 @@ func runTestCase(t *testing.T, testCase configConsolidationTestCase, subCmd stri
509509
ts.CmdArgs = append([]string{"k6", subCmd}, testCase.options.cli...)
510510
ts.Env = state.BuildEnvMap(testCase.options.env)
511511
if testCase.options.fs != nil {
512-
ts.GlobalState.FS = testCase.options.fs
512+
ts.FS = testCase.options.fs
513513
}
514514

515515
rootCmd := newRootCommand(ts.GlobalState)

internal/cmd/launcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func k6buildProvision(gs *state.GlobalState, deps k6deps.Dependencies) (commandE
252252
func formatDependencies(deps map[string]string) string {
253253
buffer := &bytes.Buffer{}
254254
for dep, version := range deps {
255-
buffer.WriteString(fmt.Sprintf("%s:%s ", dep, version))
255+
fmt.Fprintf(buffer, "%s:%s ", dep, version)
256256
}
257257
return strings.Trim(buffer.String(), " ")
258258
}

internal/cmd/launcher_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ func TestLauncherLaunch(t *testing.T) {
210210
k6Args = append(k6Args, scriptPath)
211211
}
212212

213-
ts.GlobalState.CmdArgs = k6Args
213+
ts.CmdArgs = k6Args
214214

215215
// k6deps uses os package to access files. So we need to use it in the global state
216-
ts.GlobalState.FS = afero.NewOsFs()
216+
ts.FS = afero.NewOsFs()
217217

218218
// NewGlobalTestState does not set the Binary provisioning flag even if we set
219219
// the K6_BINARY_PROVISIONING variable in the global state, so we do it manually
220-
ts.GlobalState.Flags.BinaryProvisioning = !tc.disableBP
220+
ts.Flags.BinaryProvisioning = !tc.disableBP
221221

222222
// the exit code is checked by the TestGlobalState when the test ends
223223
ts.ExpectedExitCode = tc.expectOsExit

internal/cmd/outputs_cloud.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func createCloudTest(gs *state.GlobalState, test *loadedAndConfiguredTest) error
3939
test.derivedConfig.Collectors[builtinOutputCloud.String()],
4040
gs.Env,
4141
"", // Historically used for -o cloud=..., no longer used (deprecated).
42-
test.derivedConfig.Options.Cloud,
43-
test.derivedConfig.Options.External,
42+
test.derivedConfig.Cloud,
43+
test.derivedConfig.External,
4444
)
4545
if err != nil {
4646
return err
@@ -51,7 +51,7 @@ func createCloudTest(gs *state.GlobalState, test *loadedAndConfiguredTest) error
5151
}
5252

5353
// If not, we continue with some validations and the creation of the test run.
54-
if err := validateRequiredSystemTags(test.derivedConfig.Options.SystemTags); err != nil {
54+
if err := validateRequiredSystemTags(test.derivedConfig.SystemTags); err != nil {
5555
return err
5656
}
5757

@@ -76,13 +76,13 @@ func createCloudTest(gs *state.GlobalState, test *loadedAndConfiguredTest) error
7676
}
7777

7878
et, err := lib.NewExecutionTuple(
79-
test.derivedConfig.Options.ExecutionSegment,
80-
test.derivedConfig.Options.ExecutionSegmentSequence,
79+
test.derivedConfig.ExecutionSegment,
80+
test.derivedConfig.ExecutionSegmentSequence,
8181
)
8282
if err != nil {
8383
return err
8484
}
85-
executionPlan := test.derivedConfig.Options.Scenarios.GetFullExecutionRequirements(et)
85+
executionPlan := test.derivedConfig.Scenarios.GetFullExecutionRequirements(et)
8686

8787
duration, testEnds := lib.GetEndOffset(executionPlan)
8888
if !testEnds {

internal/cmd/test_load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (lt *loadedTest) consolidateDeriveAndValidateConfig(
217217
// If parsing the threshold expressions failed, consider it as an
218218
// invalid configuration error.
219219
if !lt.preInitState.RuntimeOptions.NoThresholds.Bool {
220-
for metricName, thresholdsDefinition := range consolidatedConfig.Options.Thresholds {
220+
for metricName, thresholdsDefinition := range consolidatedConfig.Thresholds {
221221
err = thresholdsDefinition.Parse()
222222
if err != nil {
223223
return nil, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)

internal/cmd/tests/cmd_run_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func asyncWaitForStdoutAndRun(
854854

855855
func injectMockSignalNotifier(ts *GlobalTestState) (sendSignal chan os.Signal) {
856856
sendSignal = make(chan os.Signal)
857-
ts.GlobalState.SignalNotify = func(c chan<- os.Signal, signals ...os.Signal) {
857+
ts.SignalNotify = func(c chan<- os.Signal, signals ...os.Signal) {
858858
isAbortNotify := false
859859
for _, s := range signals {
860860
if s == os.Interrupt {
@@ -871,7 +871,7 @@ func injectMockSignalNotifier(ts *GlobalTestState) (sendSignal chan os.Signal) {
871871
close(sendSignal)
872872
}()
873873
}
874-
ts.GlobalState.SignalStop = func(_ chan<- os.Signal) { /* noop */ }
874+
ts.SignalStop = func(_ chan<- os.Signal) { /* noop */ }
875875
return sendSignal
876876
}
877877

internal/cmd/ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func showProgress(ctx context.Context, gs *state.GlobalState, pbs []*pb.Progress
284284
termWidth := defaultTermWidth
285285
if gs.Stdout.IsTTY {
286286
tw, _, err := term.GetSize(gs.Stdout.RawOutFd)
287-
if !(tw > 0) || err != nil {
287+
if (tw <= 0) || err != nil {
288288
terminalSizeUnknown = true
289289
logger.WithError(err).Debug("can't get terminal size")
290290
} else {

internal/js/bundle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ func (b *Bundle) setInitGlobals(rt *sobek.Runtime, vu *moduleVUImpl, modSys *mod
493493
if err != nil {
494494
return nil, err
495495
}
496-
if !(strings.HasPrefix(filename, "file://") || filepath.IsAbs(filename)) {
496+
if !strings.HasPrefix(filename, "file://") && !filepath.IsAbs(filename) {
497497
otherPath, shouldWarn := modSys.ShouldWarnOnParentDirNotMatchingCurrentModuleParentDir(vu, pwd)
498498
logger := b.preInitState.Logger
499499
if shouldWarn {

internal/js/modules/k6/browser/browser/browser_context_mapping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func mapBrowserContext(vu moduleVU, bc *common.BrowserContext) mapping { //nolin
120120
var runInTaskQueue func(p *common.Page) (bool, error)
121121
if popts.PredicateFn != nil {
122122
runInTaskQueue = func(p *common.Page) (bool, error) {
123-
tq := vu.taskQueueRegistry.get(ctx, p.TargetID())
123+
tq := vu.get(ctx, p.TargetID())
124124

125125
var rtn bool
126126
var err error

0 commit comments

Comments
 (0)