From 35c64694ef47b9e9683e186feeff525dea0da8ac Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:36:15 +0530 Subject: [PATCH 1/6] Resource Tested for JSON marshalling : Workflow --- github/actions_workflows_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 45a161b6587..8cf7d591745 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -458,3 +458,35 @@ func TestActionsService_DisableWorkflowByFileName(t *testing.T) { return client.Actions.DisableWorkflowByFileName(ctx, "o", "r", "main.yml") }) } + +func TestWorkflow_Marshal(t *testing.T) { + testJSONMarshal(t, &Workflow{}, "{}") + + u := &Workflow{ + ID: Int64(1), + NodeID: String("nid"), + Name: String("n"), + Path: String("p"), + State: String("s"), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + URL: String("u"), + HTMLURL: String("h"), + BadgeURL: String("b"), + } + + want := `{ + "id": 1, + "node_id": "nid", + "name": "n", + "path": "p", + "state": "s", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "url": "u", + "html_url": "h", + "badge_url": "b" + }` + + testJSONMarshal(t, u, want) +} From b3e4d6600f3645086486de5105abbeea6ca825be Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:39:37 +0530 Subject: [PATCH 2/6] Resource Tested for JSON marshalling : Workflows --- github/actions_workflows_test.go | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 8cf7d591745..dc7b2048a74 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -490,3 +490,43 @@ func TestWorkflow_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestWorkflows_Marshal(t *testing.T) { + testJSONMarshal(t, &Workflows{}, "{}") + + u := &Workflows{ + TotalCount: Int(1), + Workflows: []*Workflow{ + { + ID: Int64(1), + NodeID: String("nid"), + Name: String("n"), + Path: String("p"), + State: String("s"), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + URL: String("u"), + HTMLURL: String("h"), + BadgeURL: String("b"), + }, + }, + } + + want := `{ + "total_count": 1, + "workflows": [{ + "id": 1, + "node_id": "nid", + "name": "n", + "path": "p", + "state": "s", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "url": "u", + "html_url": "h", + "badge_url": "b" + }] + }` + + testJSONMarshal(t, u, want) +} From b1bfad77dfd1f30a4b93ab94518d5c341d67f56d Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:41:57 +0530 Subject: [PATCH 3/6] Resource Tested for JSON marshalling : WorkflowBill --- github/actions_workflows_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index dc7b2048a74..c7cffa2995f 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -530,3 +530,17 @@ func TestWorkflows_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestWorkflowBill_Marshal(t *testing.T) { + testJSONMarshal(t, &WorkflowBill{}, "{}") + + u := &WorkflowBill{ + TotalMS: Int64(1), + } + + want := `{ + "total_ms": 1 + }` + + testJSONMarshal(t, u, want) +} From 24a96b46886d9891d6298539497cac0123cacf72 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:44:17 +0530 Subject: [PATCH 4/6] Resource Tested for JSON marshalling : WorkflowEnvironment --- github/actions_workflows_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index c7cffa2995f..7dc249bbf5e 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -544,3 +544,33 @@ func TestWorkflowBill_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestWorkflowEnvironment_Marshal(t *testing.T) { + testJSONMarshal(t, &WorkflowEnvironment{}, "{}") + + u := &WorkflowEnvironment{ + Ubuntu: &WorkflowBill{ + TotalMS: Int64(1), + }, + MacOS: &WorkflowBill{ + TotalMS: Int64(1), + }, + Windows: &WorkflowBill{ + TotalMS: Int64(1), + }, + } + + want := `{ + "UBUNTU": { + "total_ms": 1 + }, + "MACOS": { + "total_ms": 1 + }, + "WINDOWS": { + "total_ms": 1 + } + }` + + testJSONMarshal(t, u, want) +} From 7b534cc16d7427e989307ddfb7c23a6f64259dd8 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:49:22 +0530 Subject: [PATCH 5/6] Resource Tested for JSON marshalling : WorkflowUsage --- github/actions_workflows_test.go | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 7dc249bbf5e..8c5b2457dfa 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -574,3 +574,37 @@ func TestWorkflowEnvironment_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestWorkflowUsage_Marshal(t *testing.T) { + testJSONMarshal(t, &WorkflowUsage{}, "{}") + + u := &WorkflowUsage{ + Billable: &WorkflowEnvironment{ + Ubuntu: &WorkflowBill{ + TotalMS: Int64(1), + }, + MacOS: &WorkflowBill{ + TotalMS: Int64(1), + }, + Windows: &WorkflowBill{ + TotalMS: Int64(1), + }, + }, + } + + want := `{ + "billable": { + "UBUNTU": { + "total_ms": 1 + }, + "MACOS": { + "total_ms": 1 + }, + "WINDOWS": { + "total_ms": 1 + } + } + }` + + testJSONMarshal(t, u, want) +} From d6a62af8c493c4418fa7d55504cb0ad7071ead6d Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 16:56:35 +0530 Subject: [PATCH 6/6] Resource Tested for JSON marshalling : CreateWorkflowDispatchEventRequest --- github/actions_workflows_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 8c5b2457dfa..60a9d91b371 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -608,3 +608,24 @@ func TestWorkflowUsage_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestCreateWorkflowDispatchEventRequest_Marshal(t *testing.T) { + testJSONMarshal(t, &CreateWorkflowDispatchEventRequest{}, "{}") + + inputs := make(map[string]interface{}, 0) + inputs["key"] = "value" + + u := &CreateWorkflowDispatchEventRequest{ + Ref: "r", + Inputs: inputs, + } + + want := `{ + "ref": "r", + "inputs": { + "key": "value" + } + }` + + testJSONMarshal(t, u, want) +}