Skip to content

Commit ed01b32

Browse files
committed
Split Copilot Space resource attributes
1 parent e619ca2 commit ed01b32

4 files changed

Lines changed: 159 additions & 25 deletions

File tree

github/copilot.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ type CopilotSpaceResource struct {
4848
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
4949
}
5050

51+
// CreateCopilotSpaceResourceAttributes represents a resource to attach when creating a Copilot Space.
52+
type CreateCopilotSpaceResourceAttributes struct {
53+
ResourceType *string `json:"resource_type,omitempty"`
54+
Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"`
55+
}
56+
57+
// UpdateCopilotSpaceResourceAttributes represents a resource to attach, update, or remove when updating a Copilot Space.
58+
type UpdateCopilotSpaceResourceAttributes struct {
59+
ID *int64 `json:"id,omitempty"`
60+
ResourceType *string `json:"resource_type,omitempty"`
61+
Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"`
62+
Destroy *bool `json:"_destroy,omitempty"`
63+
}
64+
5165
// CopilotSpaceMetadata represents metadata specific to a Copilot Space resource type.
5266
type CopilotSpaceMetadata struct {
5367
RepositoryID *int64 `json:"repository_id,omitempty"`
@@ -64,20 +78,20 @@ type CopilotSpaceMetadata struct {
6478

6579
// CreateOrganizationCopilotSpaceRequest represents a request to create a Copilot Space.
6680
type CreateOrganizationCopilotSpaceRequest struct {
67-
Name string `json:"name"`
68-
Description *string `json:"description,omitempty"`
69-
GeneralInstructions *string `json:"general_instructions,omitempty"`
70-
BaseRole *string `json:"base_role,omitempty"`
71-
ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"`
81+
Name string `json:"name"`
82+
Description *string `json:"description,omitempty"`
83+
GeneralInstructions *string `json:"general_instructions,omitempty"`
84+
BaseRole *string `json:"base_role,omitempty"`
85+
ResourcesAttributes []*CreateCopilotSpaceResourceAttributes `json:"resources_attributes,omitempty"`
7286
}
7387

7488
// UpdateOrganizationCopilotSpaceRequest represents a request to update a Copilot Space.
7589
type UpdateOrganizationCopilotSpaceRequest struct {
76-
Name *string `json:"name,omitempty"`
77-
Description *string `json:"description,omitempty"`
78-
GeneralInstructions *string `json:"general_instructions,omitempty"`
79-
BaseRole *string `json:"base_role,omitempty"`
80-
ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"`
90+
Name *string `json:"name,omitempty"`
91+
Description *string `json:"description,omitempty"`
92+
GeneralInstructions *string `json:"general_instructions,omitempty"`
93+
BaseRole *string `json:"base_role,omitempty"`
94+
ResourcesAttributes []*UpdateCopilotSpaceResourceAttributes `json:"resources_attributes,omitempty"`
8195
}
8296

8397
// CopilotSpacesList represents a list of Copilot Spaces.

github/copilot_test.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) {
562562
},
563563
}
564564

565-
assertNoDiff(t, want, got)
565+
if !cmp.Equal(want, got) {
566+
t.Errorf("CopilotService returned %+v, want %+v", got, want)
567+
}
566568

567569
const methodName = "ListCopilotSeats"
568570

@@ -1194,7 +1196,9 @@ func TestCopilotService_GetOrganizationCopilotSpace(t *testing.T) {
11941196
BaseRole: "read",
11951197
}
11961198

1197-
assertNoDiff(t, want, got)
1199+
if !cmp.Equal(want, got) {
1200+
t.Errorf("CopilotService returned %+v, want %+v", got, want)
1201+
}
11981202

11991203
const methodName = "GetOrganizationCopilotSpace"
12001204

@@ -1221,7 +1225,7 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) {
12211225
Description: Ptr("Organization space for team planning"),
12221226
GeneralInstructions: Ptr("Help the team with planning tasks"),
12231227
BaseRole: Ptr("no_access"),
1224-
ResourcesAttributes: []*CopilotSpaceResource{
1228+
ResourcesAttributes: []*CreateCopilotSpaceResourceAttributes{
12251229
{
12261230
ResourceType: Ptr("free_text"),
12271231
Metadata: &CopilotSpaceMetadata{
@@ -1273,8 +1277,8 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) {
12731277
Height: Ptr(640),
12741278
Width: Ptr(480),
12751279
},
1276-
CreatedAt: refTimestamp(1676450100),
1277-
UpdatedAt: refTimestamp(1676450400),
1280+
CreatedAt: &Timestamp{referenceTime},
1281+
UpdatedAt: &Timestamp{referenceTime},
12781282
},
12791283
},
12801284
}
@@ -1320,12 +1324,12 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) {
13201324
"metadata": {
13211325
"copilot_chat_attachment_id": 123,
13221326
"media_type": "image/png",
1323-
"url": "https://test.com/image.png",
1327+
"url": "https://example.com/image.png",
13241328
"height": 640,
13251329
"width": 480
13261330
},
1327-
"created_at": "2023-02-15T08:35:00Z",
1328-
"updated_at": "2023-02-15T08:40:00Z"
1331+
"created_at": `+referenceTimeStr+`,
1332+
"updated_at": `+referenceTimeStr+`
13291333
}
13301334
]
13311335
}`)
@@ -1337,7 +1341,9 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) {
13371341
t.Errorf("Copilot.CreateOrganizationCopilotSpace returned error: %v", err)
13381342
}
13391343

1340-
assertNoDiff(t, want, got)
1344+
if !cmp.Equal(want, got) {
1345+
t.Errorf("CopilotService returned %+v, want %+v", got, want)
1346+
}
13411347

13421348
const methodName = "CreateOrganizationCopilotSpace"
13431349

@@ -1364,7 +1370,7 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) {
13641370
Description: Ptr("Updated organization space for team planning"),
13651371
GeneralInstructions: Ptr("Help the team with updated planning tasks"),
13661372
BaseRole: Ptr("read"),
1367-
ResourcesAttributes: []*CopilotSpaceResource{
1373+
ResourcesAttributes: []*UpdateCopilotSpaceResourceAttributes{
13681374
{
13691375
ID: Ptr(int64(101)),
13701376
ResourceType: Ptr("free_text"),
@@ -1373,6 +1379,10 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) {
13731379
Text: Ptr("Our team follows agile methodology"),
13741380
},
13751381
},
1382+
{
1383+
ID: Ptr(int64(102)),
1384+
Destroy: Ptr(true),
1385+
},
13761386
},
13771387
}
13781388

@@ -1453,7 +1463,9 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) {
14531463
t.Errorf("Copilot.UpdateOrganizationCopilotSpace returned error: %v", err)
14541464
}
14551465

1456-
assertNoDiff(t, want, got)
1466+
if !cmp.Equal(want, got) {
1467+
t.Errorf("CopilotService returned %+v, want %+v", got, want)
1468+
}
14571469

14581470
const methodName = "UpdateOrganizationCopilotSpace"
14591471

github/github-accessors.go

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

0 commit comments

Comments
 (0)