Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds missing struct omitempty tags to the Parent struct #435

Merged
merged 1 commit into from Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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