Skip to content

Commit

Permalink
adds missing struct omitempty tags to the Parent struct (#435)
Browse files Browse the repository at this point in the history
updates TestIssueFields_MarshalJSON_OmitsEmptyFields to check for ignored parent fields
  • Loading branch information
cmcpasserby committed Jan 25, 2022
1 parent 74ae2b9 commit 3555edb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions issue.go
Expand Up @@ -283,8 +283,8 @@ type Progress struct {

// Parent represents the parent of a Jira issue, to be used with subtask issue types.
type Parent struct {
ID string `json:"id,omitempty" structs:"id"`
Key string `json:"key,omitempty" structs:"key"`
ID string `json:"id,omitempty" structs:"id,omitempty"`
Key string `json:"key,omitempty" structs:"key,omitempty"`
}

// Time represents the Time definition of Jira as a time.Time of go
Expand Down
8 changes: 7 additions & 1 deletion issue_test.go
Expand Up @@ -1031,6 +1031,7 @@ func TestIssueFields_MarshalJSON_OmitsEmptyFields(t *testing.T) {
Name: "Story",
},
Labels: []string{"aws-docker"},
Parent: &Parent{Key: "FOO-300"},
}

rawdata, err := json.Marshal(i)
Expand All @@ -1050,6 +1051,12 @@ func TestIssueFields_MarshalJSON_OmitsEmptyFields(t *testing.T) {
t.Error("Expected non nil error, received nil")
}

// verify Parent nil values are being omitted
_, err = issuef.String("parent/id")
if err == nil {
t.Error("Expected non nil err, received nil")
}

// verify that the field that should be there, is.
name, err := issuef.String("issuetype/name")
if err != nil {
Expand All @@ -1059,7 +1066,6 @@ func TestIssueFields_MarshalJSON_OmitsEmptyFields(t *testing.T) {
if name != "Story" {
t.Errorf("Expected Story, received %s", name)
}

}

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

0 comments on commit 3555edb

Please sign in to comment.