Skip to content

Commit

Permalink
feat: added scriptPath to param event
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Feb 6, 2024
1 parent 4b94432 commit 1bc7603
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dashboard/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ type paramData struct {
EndOffset time.Duration `json:"endOffset,omitempty"`
Period time.Duration `json:"period,omitempty"`
Tags []string `json:"tags,omitempty"`
ScriptPath string `json:"scriptPath,omitempty"`
}

func newParamData(params *output.Params) *paramData {
Expand All @@ -240,6 +241,10 @@ func newParamData(params *output.Params) *paramData {
param.Scenarios = append(param.Scenarios, name)
}

if params.ScriptPath != nil {
param.ScriptPath = params.ScriptPath.String()
}

return param
}

Expand Down
8 changes: 8 additions & 0 deletions dashboard/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package dashboard

import (
"fmt"
"net/url"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -291,12 +292,19 @@ func Test_newParamData(t *testing.T) {
param := newParamData(params)

assert.Len(t, param.Scenarios, 2)
assert.Empty(t, param.ScriptPath)

params.ScriptOptions.Scenarios = nil

u, err := url.Parse("file:///tmp/script.js")
assert.NoError(t, err)

params.ScriptPath = u

param = newParamData(params)

assert.Len(t, param.Scenarios, 0)
assert.Equal(t, param.ScriptPath, "file:///tmp/script.js")
}

func Test_paramData_With(t *testing.T) {
Expand Down

0 comments on commit 1bc7603

Please sign in to comment.