Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions github/enterprise_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) {

mux.HandleFunc("/enterprises/e/properties/schema", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
testBody(t, r, `{"properties":[{"property_name":"name","value_type":"single_select","required":true},{"property_name":"service","value_type":"string"}]}`+"\n")
testBody(t, r, `{"properties":[{"property_name":"name","value_type":"single_select","required":true,"default_value":null},{"property_name":"service","value_type":"string","default_value":null}]}`+"\n")
fmt.Fprint(w, `[
{
"property_name": "name",
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestEnterpriseService_GetCustomProperty(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) {
property, _, err := client.Enterprise.CreateOrUpdateCustomProperty(ctx, "e", "name", &CustomProperty{
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand All @@ -236,7 +236,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down
2 changes: 1 addition & 1 deletion github/event_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13735,7 +13735,7 @@ func TestCustomPropertyEvent_Marshal(t *testing.T) {
ValueType: "single_select",
SourceType: Ptr("enterprise"),
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down
8 changes: 0 additions & 8 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions github/orgs_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type CustomProperty struct {
ValueType string `json:"value_type"`
// Whether the property is required.
Required *bool `json:"required,omitempty"`
// Default value of the property.
DefaultValue *string `json:"default_value,omitempty"`
// Default value of the property. Can be null, string or array of strings.
DefaultValue any `json:"default_value"`
// Short description of the property.
Description *string `json:"description,omitempty"`
// An ordered list of the allowed values of the property. The property can have up to 200
Expand Down
54 changes: 49 additions & 5 deletions github/orgs_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
"property_name": "team",
"value_type": "string",
"description": "Team owning the repository"
},
{
"property_name": "multi_select_property",
"value_type": "multi_select",
"default_value": ["production", "development"]
}
]`)
})
Expand All @@ -56,7 +61,7 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand All @@ -70,6 +75,11 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
ValueType: "string",
Description: Ptr("Team owning the repository"),
},
{
PropertyName: Ptr("multi_select_property"),
ValueType: "multi_select",
DefaultValue: []any{"production", "development"},
},
}
if !cmp.Equal(properties, want) {
t.Errorf("Organizations.GetAllCustomProperties returned %+v, want %+v", properties, want)
Expand All @@ -92,7 +102,11 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {

mux.HandleFunc("/orgs/o/properties/schema", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
testBody(t, r, `{"properties":[{"property_name":"name","value_type":"single_select","required":true},{"property_name":"service","value_type":"string"}]}`+"\n")
testBody(t, r, fmt.Sprintf(`{"properties":[%s,%s,%s,%s]}`+"\n",
`{"property_name":"name","value_type":"single_select","required":true,"default_value":null}`,
`{"property_name":"service","value_type":"string","default_value":null}`,
`{"property_name":"multi_select_property","value_type":"multi_select","default_value":["production","development"]}`,
`{"property_name":"multi_select_property_null","value_type":"multi_select","default_value":null}`))
fmt.Fprint(w, `[
{
"property_name": "name",
Expand All @@ -102,6 +116,16 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {
{
"property_name": "service",
"value_type": "string"
},
{
"property_name": "multi_select_property",
"value_type": "multi_select",
"default_value": ["production", "development"]
},
{
"property_name": "multi_select_property_null",
"value_type": "multi_select",
"default_value": null
}
]`)
})
Expand All @@ -117,6 +141,16 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {
PropertyName: Ptr("service"),
ValueType: "string",
},
{
PropertyName: Ptr("multi_select_property"),
ValueType: "multi_select",
DefaultValue: []any{"production", "development"},
},
{
PropertyName: Ptr("multi_select_property_null"),
ValueType: "multi_select",
DefaultValue: nil,
},
})
if err != nil {
t.Errorf("Organizations.CreateOrUpdateCustomProperties returned error: %v", err)
Expand All @@ -132,6 +166,16 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) {
PropertyName: Ptr("service"),
ValueType: "string",
},
{
PropertyName: Ptr("multi_select_property"),
ValueType: "multi_select",
DefaultValue: []any{"production", "development"},
},
{
PropertyName: Ptr("multi_select_property_null"),
ValueType: "multi_select",
DefaultValue: nil,
},
}

if !cmp.Equal(properties, want) {
Expand Down Expand Up @@ -179,7 +223,7 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down Expand Up @@ -223,7 +267,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) {
property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand All @@ -236,7 +280,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) {
PropertyName: Ptr("name"),
ValueType: "single_select",
Required: Ptr(true),
DefaultValue: Ptr("production"),
DefaultValue: "production",
Description: Ptr("Prod or dev environment"),
AllowedValues: []string{"production", "development"},
ValuesEditableBy: Ptr("org_actors"),
Expand Down
Loading