Skip to content

Commit

Permalink
Resource Tested for JSON marshalling : Jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar23sj committed Jun 23, 2021
1 parent 1caa917 commit 110ea20
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions github/actions_workflow_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,67 @@ func TestWorkflowJob_Marshal(t *testing.T) {

testJSONMarshal(t, u, want)
}

func TestJobs_Marshal(t *testing.T) {
testJSONMarshal(t, &Jobs{}, "{}")

u := &Jobs{
TotalCount: Int(1),
Jobs: []*WorkflowJob{
{
ID: Int64(1),
RunID: Int64(1),
RunURL: String("r"),
NodeID: String("n"),
HeadSHA: String("h"),
URL: String("u"),
HTMLURL: String("h"),
Status: String("s"),
Conclusion: String("c"),
StartedAt: &Timestamp{referenceTime},
CompletedAt: &Timestamp{referenceTime},
Name: String("n"),
Steps: []*TaskStep{
{
Name: String("n"),
Status: String("s"),
Conclusion: String("c"),
Number: Int64(1),
StartedAt: &Timestamp{referenceTime},
CompletedAt: &Timestamp{referenceTime},
},
},
CheckRunURL: String("c"),
},
},
}

want := `{
"total_count": 1,
"jobs": [{
"id": 1,
"run_id": 1,
"run_url": "r",
"node_id": "n",
"head_sha": "h",
"url": "u",
"html_url": "h",
"status": "s",
"conclusion": "c",
"started_at": ` + referenceTimeStr + `,
"completed_at": ` + referenceTimeStr + `,
"name": "n",
"steps": [{
"name": "n",
"status": "s",
"conclusion": "c",
"number": 1,
"started_at": ` + referenceTimeStr + `,
"completed_at": ` + referenceTimeStr + `
}],
"check_run_url": "c"
}]
}`

testJSONMarshal(t, u, want)
}

0 comments on commit 110ea20

Please sign in to comment.