Skip to content

Commit df12a08

Browse files
complete struct fields & rename option type
1 parent 98b5647 commit df12a08

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

pkg/github/issue_fields.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,26 @@ import (
1616

1717
// IssueField represents an organization-level issue field definition.
1818
type IssueField struct {
19-
ID int64 `json:"id"`
20-
NodeID string `json:"node_id"`
21-
Name string `json:"name"`
22-
Description string `json:"description,omitempty"`
23-
DataType string `json:"data_type"`
24-
Options []IssueFieldOption `json:"options,omitempty"`
25-
CreatedAt string `json:"created_at"`
26-
UpdatedAt string `json:"updated_at"`
19+
ID int64 `json:"id"`
20+
NodeID string `json:"node_id"`
21+
Name string `json:"name"`
22+
Description string `json:"description,omitempty"`
23+
DataType string `json:"data_type"`
24+
Visibility string `json:"visibility"`
25+
Options []IssueSingleSelectFieldOption `json:"options,omitempty"`
26+
CreatedAt string `json:"created_at"`
27+
UpdatedAt string `json:"updated_at"`
2728
}
2829

29-
// IssueFieldOption represents an option for a single_select issue field.
30-
type IssueFieldOption struct {
31-
ID int64 `json:"id"`
32-
Name string `json:"name"`
30+
// IssueSingleSelectFieldOption represents an option for a single_select issue field.
31+
type IssueSingleSelectFieldOption struct {
32+
ID int64 `json:"id"`
33+
Name string `json:"name"`
34+
Description string `json:"description,omitempty"`
35+
Color string `json:"color"`
36+
Priority int64 `json:"priority"`
37+
CreatedAt string `json:"created_at"`
38+
UpdatedAt string `json:"updated_at"`
3339
}
3440

3541
// ListOrgIssueFields creates a tool to list issue field definitions for an organization.

pkg/github/issue_fields_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func Test_ListOrgIssueFields(t *testing.T) {
3434
Name: "DRI",
3535
Description: "Directly responsible individual",
3636
DataType: "text",
37+
Visibility: "organization_members_only",
3738
CreatedAt: "2024-12-11T14:39:09Z",
3839
UpdatedAt: "2024-12-11T14:39:09Z",
3940
},
@@ -43,10 +44,11 @@ func Test_ListOrgIssueFields(t *testing.T) {
4344
Name: "Priority",
4445
Description: "Level of importance",
4546
DataType: "single_select",
46-
Options: []IssueFieldOption{
47-
{ID: 1, Name: "High"},
48-
{ID: 2, Name: "Medium"},
49-
{ID: 3, Name: "Low"},
47+
Visibility: "all",
48+
Options: []IssueSingleSelectFieldOption{
49+
{ID: 1, Name: "High", Color: "red", Priority: 1, CreatedAt: "2024-12-11T14:39:09Z", UpdatedAt: "2024-12-11T14:39:09Z"},
50+
{ID: 2, Name: "Medium", Color: "yellow", Priority: 2, CreatedAt: "2024-12-11T14:39:09Z", UpdatedAt: "2024-12-11T14:39:09Z"},
51+
{ID: 3, Name: "Low", Color: "gray", Priority: 3, CreatedAt: "2024-12-11T14:39:09Z", UpdatedAt: "2024-12-11T14:39:09Z"},
5052
},
5153
CreatedAt: "2024-12-11T14:39:09Z",
5254
UpdatedAt: "2024-12-11T14:39:09Z",
@@ -161,10 +163,12 @@ func Test_ListOrgIssueFields(t *testing.T) {
161163
assert.Equal(t, expected.ID, returnedFields[i].ID)
162164
assert.Equal(t, expected.Name, returnedFields[i].Name)
163165
assert.Equal(t, expected.DataType, returnedFields[i].DataType)
166+
assert.Equal(t, expected.Visibility, returnedFields[i].Visibility)
164167
if expected.Options != nil {
165168
require.Equal(t, len(expected.Options), len(returnedFields[i].Options))
166169
for j, opt := range expected.Options {
167170
assert.Equal(t, opt.Name, returnedFields[i].Options[j].Name)
171+
assert.Equal(t, opt.Color, returnedFields[i].Options[j].Color)
168172
}
169173
}
170174
}

0 commit comments

Comments
 (0)