-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Implement Custom Properties #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
65e9873
Create CustomProperty struct
liaodaniel ecc77c2
Add CreateOrUpdateCustomProperty function
liaodaniel 93faa5b
Add GetCustomProperty function
liaodaniel 2f48a7d
Add RemoveCustomProperty function
liaodaniel 9bda84c
Add GetAllCustomProperties function
liaodaniel d6c57a4
Add CreateOrUpdateCustomProperties function
liaodaniel d24c1e3
Add CreateOrUpdateCustomPropertyValuesForRepos function
liaodaniel dc2238b
Add ListCustomPropertyValues function
liaodaniel 05782e5
Match the ordering with the API docs
liaodaniel 0b1aa7b
Add openapi metadata
liaodaniel 2967adc
Address the PR comments
liaodaniel 756900a
Comment on PropertyName as pointer with omitempty
liaodaniel 74b47ef
Merge branch 'master' into support_repo_custom_props
liaodaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add CreateOrUpdateCustomProperty function
- Loading branch information
commit ecc77c200e0bf66bb9d9ebace873d11791fbdbae
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // Copyright 2023 The go-github AUTHORS. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by a BSD-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package github | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/http" | ||
| "testing" | ||
|
|
||
| "github.com/google/go-cmp/cmp" | ||
| ) | ||
|
|
||
| func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { | ||
| client, mux, _, teardown := setup() | ||
| defer teardown() | ||
|
|
||
| mux.HandleFunc("/orgs/o/properties/schema/name", func(w http.ResponseWriter, r *http.Request) { | ||
| testMethod(t, r, "PUT") | ||
| fmt.Fprint(w, `{ | ||
| "property_name": "name", | ||
| "value_type": "single_select", | ||
| "required": true, | ||
| "default_value": "production", | ||
| "description": "Prod or dev environment", | ||
| "allowed_values":[ | ||
| "production", | ||
| "development" | ||
| ] | ||
| }`) | ||
| }) | ||
|
|
||
| ctx := context.Background() | ||
| property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{ | ||
| ValueType: "single_select", | ||
| Required: Bool(true), | ||
| DefaultValue: String("production"), | ||
| Description: String("Prod or dev environment"), | ||
| AllowedValues: []string{"production", "development"}, | ||
| }) | ||
| if err != nil { | ||
| t.Errorf("Organizations.CreateOrUpdateCustomProperty returned error: %v", err) | ||
| } | ||
|
|
||
| want := &CustomProperty{ | ||
| PropertyName: String("name"), | ||
| ValueType: "single_select", | ||
| Required: Bool(true), | ||
| DefaultValue: String("production"), | ||
| Description: String("Prod or dev environment"), | ||
| AllowedValues: []string{"production", "development"}, | ||
| } | ||
| if !cmp.Equal(property, want) { | ||
| t.Errorf("Organizations.CreateOrUpdateCustomProperty returned %+v, want %+v", property, want) | ||
| } | ||
|
|
||
| const methodName = "CreateOrUpdateCustomProperty" | ||
|
|
||
| testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { | ||
| got, resp, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", nil) | ||
| if got != nil { | ||
| t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) | ||
| } | ||
| return resp, err | ||
| }) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.