Skip to content
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

Add type field to DeploymentBranchPolicy #2957

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions github/github-accessors.go

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

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

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

2 changes: 2 additions & 0 deletions github/repos_deployment_branch_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type DeploymentBranchPolicy struct {
Name *string `json:"name,omitempty"`
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Type *string `json:"type,omitempty"`
}

// DeploymentBranchPolicyResponse represents the slightly different format of response that comes back when you list deployment branch policies.
Expand All @@ -26,6 +27,7 @@ type DeploymentBranchPolicyResponse struct {
// DeploymentBranchPolicyRequest represents a deployment branch policy request.
type DeploymentBranchPolicyRequest struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
}

// ListDeploymentBranchPolicies lists the deployment branch policies for an environment.
Expand Down
6 changes: 3 additions & 3 deletions github/repos_deployment_branch_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ func TestRepositoriesService_CreateDeploymentBranchPolicy(t *testing.T) {

mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
fmt.Fprint(w, `{"id":1}`)
fmt.Fprint(w, `{"id":1, "type":"branch"}`)
})

ctx := context.Background()
got, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, "o", "r", "e", &DeploymentBranchPolicyRequest{Name: String("n")})
got, _, err := client.Repositories.CreateDeploymentBranchPolicy(ctx, "o", "r", "e", &DeploymentBranchPolicyRequest{Name: String("n"), Type: String("branch")})
if err != nil {
t.Errorf("Repositories.CreateDeploymentBranchPolicy returned error: %v", err)
}

want := &DeploymentBranchPolicy{ID: Int64(1)}
want := &DeploymentBranchPolicy{ID: Int64(1), Type: String("branch")}
if !reflect.DeepEqual(got, want) {
t.Errorf("Repositories.CreateDeploymentBranchPolicy = %+v, want %+v", got, want)
}
Expand Down