Skip to content

Commit

Permalink
fixup! k6runner: add check metadata and type to remote runner requests
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre committed Oct 9, 2024
1 parent be9a6d7 commit 5ef0166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions internal/k6runner/k6runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ type CheckInfo struct {
Metadata map[string]any `json:"metadata"`
}

// FromSM populates the given Check from the information of the SM check. Existing fields are overwritten.
func (c CheckInfo) FromSM(smc sm.Check) CheckInfo {
c.Type = smc.Type().String()

if c.Metadata == nil {
c.Metadata = map[string]any{}
// CheckInfoFromSM returns a CheckInfo from the information of the given SM check.
func CheckInfoFromSM(smc sm.Check) CheckInfo {
ci := CheckInfo{
Metadata: map[string]any{},
}
c.Metadata["id"] = smc.Id
c.Metadata["tenantID"] = smc.TenantId
c.Metadata["created"] = smc.Created
c.Metadata["modified"] = smc.Modified

return c
ci.Type = smc.Type().String()
ci.Metadata["id"] = smc.Id
ci.Metadata["tenantID"] = smc.TenantId
ci.Metadata["created"] = smc.Created
ci.Metadata["modified"] = smc.Modified

return ci
}

// ErrNoTimeout is returned by [Runner] implementations if the supplied script has a timeout of zero.
Expand Down
2 changes: 1 addition & 1 deletion internal/k6runner/k6runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCheckInfoFromSM(t *testing.T) {
},
}

ci := CheckInfo{}.FromSM(check)
ci := CheckInfoFromSM(check)

require.Equal(t, sm.CheckTypeBrowser.String(), ci.Type)
require.Equal(t, map[string]any{
Expand Down

0 comments on commit 5ef0166

Please sign in to comment.