diff --git a/github/enterprise_organization_properties_test.go b/github/enterprise_organization_properties_test.go index 2248285bd3f..567676eafb3 100644 --- a/github/enterprise_organization_properties_test.go +++ b/github/enterprise_organization_properties_test.go @@ -38,7 +38,7 @@ func TestEnterpriseService_GetOrganizationCustomPropertySchema(t *testing.T) { Properties: []*CustomProperty{ { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team name"), }, }, @@ -111,7 +111,7 @@ func TestEnterpriseService_GetOrganizationCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team name"), } diff --git a/github/enterprise_properties_test.go b/github/enterprise_properties_test.go index 5aa524f4ed2..94bf1db966c 100644 --- a/github/enterprise_properties_test.go +++ b/github/enterprise_properties_test.go @@ -53,7 +53,7 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -62,11 +62,11 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) { }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team owning the repository"), }, } @@ -109,12 +109,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { properties, _, err := client.Enterprise.CreateOrUpdateCustomProperties(ctx, "e", []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, }) if err != nil { @@ -124,12 +124,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, } @@ -176,7 +176,7 @@ func TestEnterpriseService_GetCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -220,7 +220,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Enterprise.CreateOrUpdateCustomProperty(ctx, "e", "name", &CustomProperty{ - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -233,7 +233,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), diff --git a/github/event_types_test.go b/github/event_types_test.go index 15881ab6cec..ec0aa1c0ba3 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -13729,7 +13729,7 @@ func TestCustomPropertyEvent_Marshal(t *testing.T) { Action: Ptr("created"), Definition: &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, SourceType: Ptr("enterprise"), Required: Ptr(true), DefaultValue: Ptr("production"), diff --git a/github/orgs_properties.go b/github/orgs_properties.go index 0c23c91b227..502713b8bac 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -12,6 +12,15 @@ import ( "fmt" ) +// Valid values for CustomProperty.ValueType. +const ( + PropertyValueTypeString = "string" + PropertyValueTypeSingleSelect = "single_select" + PropertyValueTypeMultiSelect = "multi_select" + PropertyValueTypeTrueFalse = "true_false" + PropertyValueTypeURL = "url" +) + // CustomProperty represents an organization custom property object. type CustomProperty struct { // PropertyName is required for most endpoints except when calling CreateOrUpdateCustomProperty; @@ -21,7 +30,7 @@ type CustomProperty struct { URL *string `json:"url,omitempty"` // SourceType is the source type of the property where it has been created. Can be one of: organization, enterprise. SourceType *string `json:"source_type,omitempty"` - // The type of the value for the property. Can be one of: string, single_select, multi_select, true_false. + // The type of the value for the property. Can be one of: string, single_select, multi_select, true_false, url. ValueType string `json:"value_type"` // Whether the property is required. Required *bool `json:"required,omitempty"` diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index 7ff20fd34c7..bac673d3eed 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -40,6 +40,13 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { "property_name": "team", "value_type": "string", "description": "Team owning the repository" + }, + { + "property_name": "documentation", + "value_type": "url", + "required": true, + "description": "Link to the documentation", + "default_value": "https://example.com/docs" } ]`) }) @@ -53,7 +60,7 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -62,13 +69,20 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team owning the repository"), }, + { + PropertyName: Ptr("documentation"), + ValueType: PropertyValueTypeURL, + Required: Ptr(true), + Description: Ptr("Link to the documentation"), + DefaultValue: Ptr("https://example.com/docs"), + }, } if !cmp.Equal(properties, want) { t.Errorf("Organizations.GetAllCustomProperties returned %+v, want %+v", properties, want) @@ -109,12 +123,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { properties, _, err := client.Organizations.CreateOrUpdateCustomProperties(ctx, "o", []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, }) if err != nil { @@ -124,12 +138,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, } @@ -176,7 +190,7 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -220,7 +234,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{ - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -233,7 +247,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"),