Skip to content

Commit 5044ba0

Browse files
refactor: ProjectV2View required fields by value
Per review (the consensus from #4202 that required response fields should be non-pointer), make ProjectV2View's required scalar fields non-pointer: id, number, name, layout, node_id, project_url and html_url. Optional (filter), nested struct (creator), timestamp and slice fields keep their existing pointer/slice forms.
1 parent 365ebfb commit 5044ba0

4 files changed

Lines changed: 40 additions & 61 deletions

File tree

‎github/github-accessors.go‎

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎github/github-accessors_test.go‎

Lines changed: 7 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎github/projects.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,13 @@ func (s *ProjectsService) AddUserProjectField(ctx context.Context, username stri
878878

879879
// ProjectV2View represents a view in a project.
880880
type ProjectV2View struct {
881-
ID *int64 `json:"id,omitempty"`
882-
Number *int `json:"number,omitempty"`
883-
Name *string `json:"name,omitempty"`
884-
Layout *string `json:"layout,omitempty"`
885-
NodeID *string `json:"node_id,omitempty"`
886-
ProjectURL *string `json:"project_url,omitempty"`
887-
HTMLURL *string `json:"html_url,omitempty"`
881+
ID int64 `json:"id"`
882+
Number int `json:"number"`
883+
Name string `json:"name"`
884+
Layout string `json:"layout"`
885+
NodeID string `json:"node_id"`
886+
ProjectURL string `json:"project_url"`
887+
HTMLURL string `json:"html_url"`
888888
Creator *User `json:"creator,omitempty"`
889889
Filter *string `json:"filter,omitempty"`
890890
// VisibleFields holds the IDs of the fields displayed in the view.

‎github/projects_test.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,10 +1686,10 @@ func TestProjectsService_CreateOrganizationProjectView(t *testing.T) {
16861686
t.Fatalf("Projects.CreateOrganizationProjectView returned error: %v", err)
16871687
}
16881688
want := &ProjectV2View{
1689-
ID: Ptr(int64(5)),
1690-
Number: Ptr(2),
1691-
Name: Ptr("My board"),
1692-
Layout: Ptr("board"),
1689+
ID: 5,
1690+
Number: 2,
1691+
Name: "My board",
1692+
Layout: "board",
16931693
SortBy: []*ProjectV2ViewSortBy{
16941694
{FieldID: Ptr(int64(9007199254740993)), Direction: Ptr("asc")},
16951695
{FieldID: Ptr(int64(456)), Direction: Ptr("desc")},
@@ -1730,7 +1730,7 @@ func TestProjectsService_CreateUserProjectView(t *testing.T) {
17301730
if err != nil {
17311731
t.Fatalf("Projects.CreateUserProjectView returned error: %v", err)
17321732
}
1733-
want := &ProjectV2View{ID: Ptr(int64(6)), Number: Ptr(3), Name: Ptr("My table"), Layout: Ptr("table")}
1733+
want := &ProjectV2View{ID: 6, Number: 3, Name: "My table", Layout: "table"}
17341734
if diff := cmp.Diff(want, view); diff != "" {
17351735
t.Errorf("Projects.CreateUserProjectView mismatch (-want +got):\n%v", diff)
17361736
}

0 commit comments

Comments
 (0)