Skip to content

Commit e9632ee

Browse files
authored
feat: Add support for URL custom property value type (#3879)
1 parent 34bb848 commit e9632ee

File tree

5 files changed

+47
-24
lines changed

5 files changed

+47
-24
lines changed

github/enterprise_organization_properties_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestEnterpriseService_GetOrganizationCustomPropertySchema(t *testing.T) {
3838
Properties: []*CustomProperty{
3939
{
4040
PropertyName: Ptr("team"),
41-
ValueType: "string",
41+
ValueType: PropertyValueTypeString,
4242
Description: Ptr("Team name"),
4343
},
4444
},
@@ -111,7 +111,7 @@ func TestEnterpriseService_GetOrganizationCustomProperty(t *testing.T) {
111111

112112
want := &CustomProperty{
113113
PropertyName: Ptr("team"),
114-
ValueType: "string",
114+
ValueType: PropertyValueTypeString,
115115
Description: Ptr("Team name"),
116116
}
117117

github/enterprise_properties_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) {
5353
want := []*CustomProperty{
5454
{
5555
PropertyName: Ptr("name"),
56-
ValueType: "single_select",
56+
ValueType: PropertyValueTypeSingleSelect,
5757
Required: Ptr(true),
5858
DefaultValue: Ptr("production"),
5959
Description: Ptr("Prod or dev environment"),
@@ -62,11 +62,11 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) {
6262
},
6363
{
6464
PropertyName: Ptr("service"),
65-
ValueType: "string",
65+
ValueType: PropertyValueTypeString,
6666
},
6767
{
6868
PropertyName: Ptr("team"),
69-
ValueType: "string",
69+
ValueType: PropertyValueTypeString,
7070
Description: Ptr("Team owning the repository"),
7171
},
7272
}
@@ -109,12 +109,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) {
109109
properties, _, err := client.Enterprise.CreateOrUpdateCustomProperties(ctx, "e", []*CustomProperty{
110110
{
111111
PropertyName: Ptr("name"),
112-
ValueType: "single_select",
112+
ValueType: PropertyValueTypeSingleSelect,
113113
Required: Ptr(true),
114114
},
115115
{
116116
PropertyName: Ptr("service"),
117-
ValueType: "string",
117+
ValueType: PropertyValueTypeString,
118118
},
119119
})
120120
if err != nil {
@@ -124,12 +124,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) {
124124
want := []*CustomProperty{
125125
{
126126
PropertyName: Ptr("name"),
127-
ValueType: "single_select",
127+
ValueType: PropertyValueTypeSingleSelect,
128128
Required: Ptr(true),
129129
},
130130
{
131131
PropertyName: Ptr("service"),
132-
ValueType: "string",
132+
ValueType: PropertyValueTypeString,
133133
},
134134
}
135135

@@ -176,7 +176,7 @@ func TestEnterpriseService_GetCustomProperty(t *testing.T) {
176176

177177
want := &CustomProperty{
178178
PropertyName: Ptr("name"),
179-
ValueType: "single_select",
179+
ValueType: PropertyValueTypeSingleSelect,
180180
Required: Ptr(true),
181181
DefaultValue: Ptr("production"),
182182
Description: Ptr("Prod or dev environment"),
@@ -220,7 +220,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) {
220220

221221
ctx := t.Context()
222222
property, _, err := client.Enterprise.CreateOrUpdateCustomProperty(ctx, "e", "name", &CustomProperty{
223-
ValueType: "single_select",
223+
ValueType: PropertyValueTypeSingleSelect,
224224
Required: Ptr(true),
225225
DefaultValue: Ptr("production"),
226226
Description: Ptr("Prod or dev environment"),
@@ -233,7 +233,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) {
233233

234234
want := &CustomProperty{
235235
PropertyName: Ptr("name"),
236-
ValueType: "single_select",
236+
ValueType: PropertyValueTypeSingleSelect,
237237
Required: Ptr(true),
238238
DefaultValue: Ptr("production"),
239239
Description: Ptr("Prod or dev environment"),

github/event_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13729,7 +13729,7 @@ func TestCustomPropertyEvent_Marshal(t *testing.T) {
1372913729
Action: Ptr("created"),
1373013730
Definition: &CustomProperty{
1373113731
PropertyName: Ptr("name"),
13732-
ValueType: "single_select",
13732+
ValueType: PropertyValueTypeSingleSelect,
1373313733
SourceType: Ptr("enterprise"),
1373413734
Required: Ptr(true),
1373513735
DefaultValue: Ptr("production"),

github/orgs_properties.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import (
1212
"fmt"
1313
)
1414

15+
// Valid values for CustomProperty.ValueType.
16+
const (
17+
PropertyValueTypeString = "string"
18+
PropertyValueTypeSingleSelect = "single_select"
19+
PropertyValueTypeMultiSelect = "multi_select"
20+
PropertyValueTypeTrueFalse = "true_false"
21+
PropertyValueTypeURL = "url"
22+
)
23+
1524
// CustomProperty represents an organization custom property object.
1625
type CustomProperty struct {
1726
// PropertyName is required for most endpoints except when calling CreateOrUpdateCustomProperty;
@@ -21,7 +30,7 @@ type CustomProperty struct {
2130
URL *string `json:"url,omitempty"`
2231
// SourceType is the source type of the property where it has been created. Can be one of: organization, enterprise.
2332
SourceType *string `json:"source_type,omitempty"`
24-
// The type of the value for the property. Can be one of: string, single_select, multi_select, true_false.
33+
// The type of the value for the property. Can be one of: string, single_select, multi_select, true_false, url.
2534
ValueType string `json:"value_type"`
2635
// Whether the property is required.
2736
Required *bool `json:"required,omitempty"`

github/orgs_properties_test.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
4040
"property_name": "team",
4141
"value_type": "string",
4242
"description": "Team owning the repository"
43+
},
44+
{
45+
"property_name": "documentation",
46+
"value_type": "url",
47+
"required": true,
48+
"description": "Link to the documentation",
49+
"default_value": "https://example.com/docs"
4350
}
4451
]`)
4552
})
@@ -53,7 +60,7 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
5360
want := []*CustomProperty{
5461
{
5562
PropertyName: Ptr("name"),
56-
ValueType: "single_select",
63+
ValueType: PropertyValueTypeSingleSelect,
5764
Required: Ptr(true),
5865
DefaultValue: Ptr("production"),
5966
Description: Ptr("Prod or dev environment"),
@@ -62,13 +69,20 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
6269
},
6370
{
6471
PropertyName: Ptr("service"),
65-
ValueType: "string",
72+
ValueType: PropertyValueTypeString,
6673
},
6774
{
6875
PropertyName: Ptr("team"),
69-
ValueType: "string",
76+
ValueType: PropertyValueTypeString,
7077
Description: Ptr("Team owning the repository"),
7178
},
79+
{
80+
PropertyName: Ptr("documentation"),
81+
ValueType: PropertyValueTypeURL,
82+
Required: Ptr(true),
83+
Description: Ptr("Link to the documentation"),
84+
DefaultValue: Ptr("https://example.com/docs"),
85+
},
7286
}
7387
if !cmp.Equal(properties, want) {
7488
t.Errorf("Organizations.GetAllCustomProperties returned %+v, want %+v", properties, want)
@@ -109,12 +123,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {
109123
properties, _, err := client.Organizations.CreateOrUpdateCustomProperties(ctx, "o", []*CustomProperty{
110124
{
111125
PropertyName: Ptr("name"),
112-
ValueType: "single_select",
126+
ValueType: PropertyValueTypeSingleSelect,
113127
Required: Ptr(true),
114128
},
115129
{
116130
PropertyName: Ptr("service"),
117-
ValueType: "string",
131+
ValueType: PropertyValueTypeString,
118132
},
119133
})
120134
if err != nil {
@@ -124,12 +138,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {
124138
want := []*CustomProperty{
125139
{
126140
PropertyName: Ptr("name"),
127-
ValueType: "single_select",
141+
ValueType: PropertyValueTypeSingleSelect,
128142
Required: Ptr(true),
129143
},
130144
{
131145
PropertyName: Ptr("service"),
132-
ValueType: "string",
146+
ValueType: PropertyValueTypeString,
133147
},
134148
}
135149

@@ -176,7 +190,7 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) {
176190

177191
want := &CustomProperty{
178192
PropertyName: Ptr("name"),
179-
ValueType: "single_select",
193+
ValueType: PropertyValueTypeSingleSelect,
180194
Required: Ptr(true),
181195
DefaultValue: Ptr("production"),
182196
Description: Ptr("Prod or dev environment"),
@@ -220,7 +234,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) {
220234

221235
ctx := t.Context()
222236
property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{
223-
ValueType: "single_select",
237+
ValueType: PropertyValueTypeSingleSelect,
224238
Required: Ptr(true),
225239
DefaultValue: Ptr("production"),
226240
Description: Ptr("Prod or dev environment"),
@@ -233,7 +247,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) {
233247

234248
want := &CustomProperty{
235249
PropertyName: Ptr("name"),
236-
ValueType: "single_select",
250+
ValueType: PropertyValueTypeSingleSelect,
237251
Required: Ptr(true),
238252
DefaultValue: Ptr("production"),
239253
Description: Ptr("Prod or dev environment"),

0 commit comments

Comments
 (0)