Skip to content

Commit

Permalink
k6runner: use non-pointer LocalRunner everywhere
Browse files Browse the repository at this point in the history
Having some methods return a pointer version becomes tricky fast
  • Loading branch information
nadiamoe authored and Ro Santalla committed Jun 19, 2024
1 parent 0a943f9 commit bde75eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/k6runner/k6runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func New(opts RunnerOpts) Runner {
logger: &logger,
}
} else {
r = &LocalRunner{
r = LocalRunner{
k6path: opts.Uri,
logger: &logger,
blacklistedIP: opts.BlacklistedIP,
Expand Down
10 changes: 6 additions & 4 deletions internal/k6runner/k6runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import (

func TestNew(t *testing.T) {
r1 := New(RunnerOpts{Uri: "k6"})
require.IsType(t, &LocalRunner{}, r1)
require.Equal(t, "", r1.(*LocalRunner).blacklistedIP)
require.IsType(t, LocalRunner{}, r1)
require.Equal(t, "", r1.(LocalRunner).blacklistedIP)

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)
require.IsType(t, LocalRunner{}, r2)
require.Equal(t, "192.168.4.0/24", r2.(LocalRunner).blacklistedIP)

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

0 comments on commit bde75eb

Please sign in to comment.