From da37ce8a188dff1ad9d388c69684f48bce491dbd Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Wed, 23 Jun 2021 16:12:58 +0530 Subject: [PATCH 1/3] Resource Tested for JSON marshalling : TaskStep --- github/actions_workflow_jobs_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 97666b3fe70..f9b9d6ab3d3 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -203,3 +203,27 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_followRedirect t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) } } + +func TestTaskStep_Marshal(t *testing.T) { + testJSONMarshal(t, &TaskStep{}, "{}") + + u := &TaskStep{ + Name: String("n"), + Status: String("s"), + Conclusion: String("c"), + Number: Int64(1), + StartedAt: &Timestamp{referenceTime}, + CompletedAt: &Timestamp{referenceTime}, + } + + want := `{ + "name": "n", + "status": "s", + "conclusion": "c", + "number": 1, + "started_at": ` + referenceTimeStr + `, + "completed_at": ` + referenceTimeStr + ` + }` + + testJSONMarshal(t, u, want) +} From 1caa917606e8bdabb5a9fd886fa4726e630f7324 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Wed, 23 Jun 2021 16:29:44 +0530 Subject: [PATCH 2/3] Resource Tested for JSON marshalling : WorkflowJob --- github/actions_workflow_jobs_test.go | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index f9b9d6ab3d3..b39ecb346a4 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -227,3 +227,59 @@ func TestTaskStep_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestWorkflowJob_Marshal(t *testing.T) { + testJSONMarshal(t, &WorkflowJob{}, "{}") + + u := &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 := `{ + "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) +} From 110ea205e10514bbfde1113bfe51194112507764 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Wed, 23 Jun 2021 16:36:53 +0530 Subject: [PATCH 3/3] Resource Tested for JSON marshalling : Jobs --- github/actions_workflow_jobs_test.go | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index b39ecb346a4..4062cc5b275 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -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) +}