Skip to content

Commit 65e64f7

Browse files
committed
Change ID type from string to int
1 parent 060aaae commit 65e64f7

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

github/github-accessors.go

Lines changed: 8 additions & 0 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: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type ProjectV2FieldOption struct {
5656
//
5757
// GitHub API docs: https://docs.github.com/rest/projects/fields
5858
type ProjectV2Field struct {
59-
ID string `json:"id,omitempty"` // The unique identifier for this field.
59+
ID *int64 `json:"id,omitempty"` // The unique identifier for this field.
6060
NodeID string `json:"node_id,omitempty"` // The GraphQL node ID for this field.
6161
Name string `json:"name,omitempty"` // The display name of the field.
6262
DataType string `json:"dataType,omitempty"` // The data type of the field (e.g., "text", "number", "date", "single_select", "multi_select").

github/projects_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func TestProjectsService_ListProjectFieldsForOrg(t *testing.T) {
281281
testFormValues(t, r, values{"q": "text", "after": "2", "before": "1"})
282282
fmt.Fprint(w, `[
283283
{
284-
"id": "field1",
284+
"id": 1,
285285
"node_id": "node_1",
286286
"name": "Status",
287287
"dataType": "single_select",
@@ -303,7 +303,7 @@ func TestProjectsService_ListProjectFieldsForOrg(t *testing.T) {
303303
"updated_at": "2012-01-02T15:04:05Z"
304304
},
305305
{
306-
"id": "field2",
306+
"id": 2,
307307
"node_id": "node_2",
308308
"name": "Priority",
309309
"dataType": "text",
@@ -327,8 +327,8 @@ func TestProjectsService_ListProjectFieldsForOrg(t *testing.T) {
327327

328328
// Validate first field (with options)
329329
field1 := fields[0]
330-
if field1.ID != "field1" || field1.Name != "Status" || field1.DataType != "single_select" {
331-
t.Errorf("First field: got ID=%s, Name=%s, DataType=%s; want field1, Status, single_select",
330+
if field1.ID == nil || *field1.ID != 1 || field1.Name != "Status" || field1.DataType != "single_select" {
331+
t.Errorf("First field: got ID=%v, Name=%s, DataType=%s; want 1, Status, single_select",
332332
field1.ID, field1.Name, field1.DataType)
333333
}
334334
if len(field1.Options) != 2 {
@@ -341,8 +341,8 @@ func TestProjectsService_ListProjectFieldsForOrg(t *testing.T) {
341341

342342
// Validate second field (without options)
343343
field2 := fields[1]
344-
if field2.ID != "field2" || field2.Name != "Priority" || field2.DataType != "text" {
345-
t.Errorf("Second field: got ID=%s, Name=%s, DataType=%s; want field2, Priority, text",
344+
if field2.ID == nil || *field2.ID != 2 || field2.Name != "Priority" || field2.DataType != "text" {
345+
t.Errorf("Second field: got ID=%v, Name=%s, DataType=%s; want 2, Priority, text",
346346
field2.ID, field2.Name, field2.DataType)
347347
}
348348
if len(field2.Options) != 0 {
@@ -382,13 +382,13 @@ func TestProjectsService_ListProjectFieldsForOrg_pagination(t *testing.T) {
382382
if after == "" && before == "" {
383383
// first request
384384
w.Header().Set("Link", "<http://example.org/orgs/o/projectsV2/1/fields?after=cursor2>; rel=\"next\"")
385-
fmt.Fprint(w, `[{"id":"field1","name":"Status","dataType":"single_select","created_at":"2011-01-02T15:04:05Z","updated_at":"2012-01-02T15:04:05Z"}]`)
385+
fmt.Fprint(w, `[{"id":1,"name":"Status","dataType":"single_select","created_at":"2011-01-02T15:04:05Z","updated_at":"2012-01-02T15:04:05Z"}]`)
386386
return
387387
}
388388
if after == "cursor2" {
389389
// second request simulates a previous link
390390
w.Header().Set("Link", "<http://example.org/orgs/o/projectsV2/1/fields?before=cursor2>; rel=\"prev\"")
391-
fmt.Fprint(w, `[{"id":"field2","name":"Priority","dataType":"text","created_at":"2011-01-02T15:04:05Z","updated_at":"2012-01-02T15:04:05Z"}]`)
391+
fmt.Fprint(w, `[{"id":2,"name":"Priority","dataType":"text","created_at":"2011-01-02T15:04:05Z","updated_at":"2012-01-02T15:04:05Z"}]`)
392392
return
393393
}
394394
// unexpected state
@@ -400,7 +400,7 @@ func TestProjectsService_ListProjectFieldsForOrg_pagination(t *testing.T) {
400400
if err != nil {
401401
t.Fatalf("first page error: %v", err)
402402
}
403-
if len(first) != 1 || first[0].ID != "field1" {
403+
if len(first) != 1 || first[0].ID == nil || *first[0].ID != 1 {
404404
t.Fatalf("unexpected first page %+v", first)
405405
}
406406
if resp.After != "cursor2" {
@@ -413,7 +413,7 @@ func TestProjectsService_ListProjectFieldsForOrg_pagination(t *testing.T) {
413413
if err != nil {
414414
t.Fatalf("second page error: %v", err)
415415
}
416-
if len(second) != 1 || second[0].ID != "field2" {
416+
if len(second) != 1 || second[0].ID == nil || *second[0].ID != 2 {
417417
t.Fatalf("unexpected second page %+v", second)
418418
}
419419
if resp2.Before != "cursor2" {
@@ -454,7 +454,7 @@ func TestProjectV2Field_Marshal(t *testing.T) {
454454
testJSONMarshal(t, &ProjectV2FieldOption{}, "{}")
455455

456456
field := &ProjectV2Field{
457-
ID: "field1",
457+
ID: Ptr(int64(1)),
458458
NodeID: "node_1",
459459
Name: "Status",
460460
DataType: "single_select",
@@ -472,14 +472,14 @@ func TestProjectV2Field_Marshal(t *testing.T) {
472472
}
473473

474474
want := `{
475-
"id": "field1",
475+
"id": 1,
476476
"node_id": "node_1",
477477
"name": "Status",
478478
"dataType": "single_select",
479479
"url": "https://api.github.com/projects/1/fields/field1",
480480
"options": [
481481
{
482-
"id": "option1",
482+
"id": "option1",
483483
"name": "Todo",
484484
"color": "blue",
485485
"description": "Tasks to be done"

0 commit comments

Comments
 (0)