Skip to content

Commit

Permalink
Merge pull request #113 from thousandeyes/labels_fix
Browse files Browse the repository at this point in the history
fix: ensures an empty array is marshalled rather than null in labels
  • Loading branch information
pedro-te authored Feb 23, 2023
2 parents 07ba4bd + 9096415 commit bed1e00
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions group_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ type GroupLabel struct {
func (t GroupLabel) MarshalJSON() ([]byte, error) {
type alias GroupLabel

if t.Tests != nil && len(*t.Tests) == 0 {
ts := make([]GenericTest, 0)
t.Tests = &ts
}

if t.Agents != nil && len(*t.Agents) == 0 {
as := make([]Agent, 0)
t.Agents = &as
}

data, err := json.Marshal((alias)(t))
if err != nil {
return nil, err
Expand Down

0 comments on commit bed1e00

Please sign in to comment.