Skip to content

Commit

Permalink
feat(DeploymentBranchPolicy): added type field
Browse files Browse the repository at this point in the history
  • Loading branch information
dion-gionet committed Oct 10, 2023
1 parent fb8f20f commit f6b7851
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
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

0 comments on commit f6b7851

Please sign in to comment.