Skip to content

Commit

Permalink
k6runner: prevent clearing ip denylist when calling WithLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre committed Jun 19, 2024
1 parent bde75eb commit 76b0439
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/k6runner/k6runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,8 @@ type LocalRunner struct {
}

func (r LocalRunner) WithLogger(logger *zerolog.Logger) Runner {
return LocalRunner{
k6path: r.k6path,
fs: r.fs,
logger: logger,
}
r.logger = logger
return r
}

func (r LocalRunner) Run(ctx context.Context, script Script) (*RunResponse, error) {
Expand Down
4 changes: 4 additions & 0 deletions internal/k6runner/k6runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func TestNew(t *testing.T) {
r2 := New(RunnerOpts{Uri: "/usr/bin/k6", BlacklistedIP: "192.168.4.0/24"})
require.IsType(t, LocalRunner{}, r2)
require.Equal(t, "192.168.4.0/24", r2.(LocalRunner).blacklistedIP)
// Ensure WithLogger preserves config.
zl := zerolog.New(io.Discard)
r2 = r2.WithLogger(&zl)
require.Equal(t, "192.168.4.0/24", r2.(LocalRunner).blacklistedIP)

r3 := New(RunnerOpts{Uri: "http://localhost:6565"})
require.IsType(t, &HttpRunner{}, r3)
Expand Down

0 comments on commit 76b0439

Please sign in to comment.