Skip to content

Commit

Permalink
Add test cases for JSON resource marshaling (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar23sj authored Jul 8, 2021
1 parent c9fec82 commit 5067660
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions github/event_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,93 @@ func TestEditChange_Marshal_BaseChange(t *testing.T) {

testJSONMarshal(t, u, want)
}

func TestProjectChange_Marshal_NameChange(t *testing.T) {
testJSONMarshal(t, &ProjectChange{}, "{}")

NameFrom := struct {
From *string `json:"from,omitempty"`
}{
From: String("NameFrom"),
}

u := &ProjectChange{
Name: &NameFrom,
Body: nil,
}

want := `{
"name": {
"from": "NameFrom"
}
}`

testJSONMarshal(t, u, want)
}

func TestProjectChange_Marshal_BodyChange(t *testing.T) {
testJSONMarshal(t, &ProjectChange{}, "{}")

BodyFrom := struct {
From *string `json:"from,omitempty"`
}{
From: String("BodyFrom"),
}

u := &ProjectChange{
Name: nil,
Body: &BodyFrom,
}

want := `{
"body": {
"from": "BodyFrom"
}
}`

testJSONMarshal(t, u, want)
}

func TestProjectCardChange_Marshal_NoteChange(t *testing.T) {
testJSONMarshal(t, &ProjectCardChange{}, "{}")

NoteFrom := struct {
From *string `json:"from,omitempty"`
}{
From: String("NoteFrom"),
}

u := &ProjectCardChange{
Note: &NoteFrom,
}

want := `{
"note": {
"from": "NoteFrom"
}
}`

testJSONMarshal(t, u, want)
}

func TestProjectColumnChange_Marshal_NameChange(t *testing.T) {
testJSONMarshal(t, &ProjectColumnChange{}, "{}")

NameFrom := struct {
From *string `json:"from,omitempty"`
}{
From: String("NameFrom"),
}

u := &ProjectColumnChange{
Name: &NameFrom,
}

want := `{
"name": {
"from": "NameFrom"
}
}`

testJSONMarshal(t, u, want)
}

0 comments on commit 5067660

Please sign in to comment.