diff --git a/internal/k6runner/k6runner.go b/internal/k6runner/k6runner.go index 128770f1..d17f6583 100644 --- a/internal/k6runner/k6runner.go +++ b/internal/k6runner/k6runner.go @@ -391,11 +391,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 []byte) (*RunResponse, error) { diff --git a/internal/k6runner/k6runner_test.go b/internal/k6runner/k6runner_test.go index 17fa3dcf..ea0e675b 100644 --- a/internal/k6runner/k6runner_test.go +++ b/internal/k6runner/k6runner_test.go @@ -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)