@@ -21,20 +21,23 @@ type projectFieldsTestQuery struct {
2121 Fields struct {
2222 Nodes []struct {
2323 ProjectV2Field struct {
24- ID githubv4.ID
25- Name githubv4.String
26- DataType githubv4.String
24+ ID githubv4.ID
25+ DatabaseID githubv4.Int `graphql:"databaseId"`
26+ Name githubv4.String
27+ DataType githubv4.String
2728 } `graphql:"... on ProjectV2Field"`
2829 ProjectV2IterationField struct {
29- ID githubv4.ID
30- Name githubv4.String
31- DataType githubv4.String
30+ ID githubv4.ID
31+ DatabaseID githubv4.Int `graphql:"databaseId"`
32+ Name githubv4.String
33+ DataType githubv4.String
3234 } `graphql:"... on ProjectV2IterationField"`
3335 ProjectV2SingleSelectField struct {
34- ID githubv4.ID
35- Name githubv4.String
36- DataType githubv4.String
37- Options []struct {
36+ ID githubv4.ID
37+ DatabaseID githubv4.Int `graphql:"databaseId"`
38+ Name githubv4.String
39+ DataType githubv4.String
40+ Options []struct {
3841 ID githubv4.String
3942 Name githubv4.String
4043 }
@@ -56,12 +59,15 @@ func fieldsQueryVars(owner string, projectNumber int) map[string]any {
5659}
5760
5861// statusFieldNode is a single-select field response node for use in mock data.
59- func statusFieldNode (id , name string , options []map [string ]any ) map [string ]any {
62+ // `nodeID` is the global node ID (e.g. "PVTSSF_lADO...") and `databaseID` is
63+ // the numeric database ID the REST API expects.
64+ func statusFieldNode (nodeID string , databaseID int , name string , options []map [string ]any ) map [string ]any {
6065 return map [string ]any {
61- "id" : id ,
62- "name" : name ,
63- "dataType" : "SINGLE_SELECT" ,
64- "options" : options ,
66+ "id" : nodeID ,
67+ "databaseId" : databaseID ,
68+ "name" : name ,
69+ "dataType" : "SINGLE_SELECT" ,
70+ "options" : options ,
6571 }
6672}
6773
@@ -89,7 +95,7 @@ func Test_ResolveProjectFieldByName_Success(t *testing.T) {
8995 projectFieldsTestQuery {},
9096 fieldsQueryVars ("octo-org" , 7 ),
9197 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
92- statusFieldNode ("12345" , "Status" , []map [string ]any {
98+ statusFieldNode ("PVTSSF_lADOBBcDeFg123" , 12345 , "Status" , []map [string ]any {
9399 {"id" : "OPT_a" , "name" : "Todo" },
94100 {"id" : "OPT_b" , "name" : "In Progress" },
95101 {"id" : "OPT_c" , "name" : "Done" },
@@ -117,7 +123,7 @@ func Test_ResolveProjectFieldByName_NotFound_ReturnsStructuredError(t *testing.T
117123 projectFieldsTestQuery {},
118124 fieldsQueryVars ("octo-org" , 7 ),
119125 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
120- statusFieldNode ("12345" , "Status" , nil ),
126+ statusFieldNode ("PVTSSF_lADOBBcDeFg123" , 12345 , "Status" , nil ),
121127 })),
122128 ),
123129 )
@@ -139,8 +145,8 @@ func Test_ResolveProjectFieldByName_Ambiguous_ReturnsStructuredError(t *testing.
139145 projectFieldsTestQuery {},
140146 fieldsQueryVars ("octo-org" , 7 ),
141147 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
142- statusFieldNode ("12345" , "Status" , nil ),
143- statusFieldNode ("67890" , "Status" , nil ),
148+ statusFieldNode ("PVTSSF_lADOBBcDeFg123" , 12345 , "Status" , nil ),
149+ statusFieldNode ("PVTSSF_lADOBBcDeFg678" , 67890 , "Status" , nil ),
144150 })),
145151 ),
146152 )
@@ -340,8 +346,8 @@ func Test_ResolveFieldNamesToIDs_Success(t *testing.T) {
340346 projectFieldsTestQuery {},
341347 fieldsQueryVars ("octo-org" , 1 ),
342348 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
343- statusFieldNode ("100" , "Status" , nil ),
344- statusFieldNode ("200" , "Priority" , nil ),
349+ statusFieldNode ("PVTSSF_lADOBBcDeFg100" , 100 , "Status" , nil ),
350+ statusFieldNode ("PVTSSF_lADOBBcDeFg200" , 200 , "Priority" , nil ),
345351 })),
346352 ),
347353 )
@@ -416,7 +422,7 @@ func Test_ProjectsWrite_UpdateProjectItem_ByName(t *testing.T) {
416422 projectFieldsTestQuery {},
417423 fieldsQueryVars ("octo-org" , 1 ),
418424 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
419- statusFieldNode ("101" , "Status" , []map [string ]any {
425+ statusFieldNode ("PVTSSF_lADOBBcDeFg101" , 101 , "Status" , []map [string ]any {
420426 {"id" : "OPT_in_progress" , "name" : "In Progress" },
421427 }),
422428 })),
@@ -453,7 +459,7 @@ func Test_ProjectsWrite_UpdateProjectItem_NameNotFound_StructuredError(t *testin
453459 projectFieldsTestQuery {},
454460 fieldsQueryVars ("octo-org" , 1 ),
455461 githubv4mock .DataResponse (fieldsResponse ([]map [string ]any {
456- statusFieldNode ("101" , "Status" , nil ),
462+ statusFieldNode ("PVTSSF_lADOBBcDeFg101" , 101 , "Status" , nil ),
457463 })),
458464 ),
459465 )
0 commit comments