Skip to content

Commit 9f746fa

Browse files
authored
Add type field to DeploymentBranchPolicy (#2957)
Fixes: #2956.
1 parent fb8f20f commit 9f746fa

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos_deployment_branch_policies.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type DeploymentBranchPolicy struct {
1515
Name *string `json:"name,omitempty"`
1616
ID *int64 `json:"id,omitempty"`
1717
NodeID *string `json:"node_id,omitempty"`
18+
Type *string `json:"type,omitempty"`
1819
}
1920

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

3133
// ListDeploymentBranchPolicies lists the deployment branch policies for an environment.

github/repos_deployment_branch_policies_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ func TestRepositoriesService_CreateDeploymentBranchPolicy(t *testing.T) {
8383

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

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

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

0 commit comments

Comments
 (0)