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
4 changes: 2 additions & 2 deletions github/enterprise_organization_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestEnterpriseService_GetOrganizationCustomPropertySchema(t *testing.T) {
Properties: []*CustomProperty{
{
PropertyName: Ptr("team"),
ValueType: "string",
ValueType: PropertyValueTypeString,
Description: Ptr("Team name"),
},
},
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestEnterpriseService_GetOrganizationCustomProperty(t *testing.T) {

want := &CustomProperty{
PropertyName: Ptr("team"),
ValueType: "string",
ValueType: PropertyValueTypeString,
Description: Ptr("Team name"),
}

Expand Down
20 changes: 10 additions & 10 deletions github/enterprise_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
},
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
},
}

Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
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 @@ -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"),
Expand Down
11 changes: 10 additions & 1 deletion github/orgs_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"`
Expand Down
34 changes: 24 additions & 10 deletions github/orgs_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]`)
})
Expand All @@ -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"),
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
},
}

Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
Loading