From 225a84bd15f76c3e6175f83940c260da3df64b76 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Tue, 25 Jan 2022 10:23:41 -0400 Subject: [PATCH] adds missing struct omitempty tags to the Parent struct updates TestIssueFields_MarshalJSON_OmitsEmptyFields to check for ignored parent fields --- issue.go | 4 ++-- issue_test.go | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/issue.go b/issue.go index 5c6c8822..084f130e 100644 --- a/issue.go +++ b/issue.go @@ -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 diff --git a/issue_test.go b/issue_test.go index 64f4fa29..ceeff9a8 100644 --- a/issue_test.go +++ b/issue_test.go @@ -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) @@ -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 { @@ -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) {