Skip to content

Commit

Permalink
Switch Workflow to pointers (google#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlewis authored Feb 22, 2020
1 parent a4527ce commit 56c2021
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 21 deletions.
24 changes: 12 additions & 12 deletions github/actions_workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import (

// Workflow represents a repository action workflow.
type Workflow struct {
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Name string `json:"name"`
Path string `json:"path"`
State string `json:"state"`
CreatedAt Timestamp `json:"created_at"`
UpdatedAt Timestamp `json:"updated_at"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
BadgeURL string `json:"badge_url"`
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Name *string `json:"name,omitempty"`
Path *string `json:"path,omitempty"`
State *string `json:"state,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
BadgeURL *string `json:"badge_url,omitempty"`
}

// Workflows represents a slice of repository action workflows.
type Workflows struct {
TotalCount int `json:"total_count"`
Workflows []*Workflow `json:"workflows"`
TotalCount *int `json:"total_count,omitempty"`
Workflows []*Workflow `json:"workflows,omitempty"`
}

// ListWorkflows lists all workflows in a repository.
Expand Down
18 changes: 9 additions & 9 deletions github/actions_workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestActionsService_ListWorkflows(t *testing.T) {
}

want := &Workflows{
TotalCount: 4,
TotalCount: Int(4),
Workflows: []*Workflow{
{ID: 72844, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
{ID: 72845, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
{ID: Int64(72844), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
{ID: Int64(72845), CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
},
}
if !reflect.DeepEqual(workflows, want) {
Expand All @@ -57,9 +57,9 @@ func TestActionsService_GetWorkflowByID(t *testing.T) {
}

want := &Workflow{
ID: 72844,
CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
ID: Int64(72844),
CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
}
if !reflect.DeepEqual(workflow, want) {
t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want)
Expand All @@ -81,9 +81,9 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) {
}

want := &Workflow{
ID: 72844,
CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
ID: Int64(72844),
CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)},
UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)},
}
if !reflect.DeepEqual(workflow, want) {
t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want)
Expand Down
88 changes: 88 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 56c2021

Please sign in to comment.