Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #49 from zshift/fix-hooks-skip-cert
Browse files Browse the repository at this point in the history
Removed omitempty, as it caused HTTP 400s when bools were false.
  • Loading branch information
cwood authored Aug 31, 2020
2 parents e1b2b93 + c29a01b commit eabec0c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bitbucket/resource_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Hook struct {
UUID string `json:"uuid,omitempty"`
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
Active bool `json:"active,omitempty"`
SkipCertVerification bool `json:"skip_cert_verification,omitempty"`
Active bool `json:"active"`
SkipCertVerification bool `json:"skip_cert_verification"`
Events []string `json:"events,omitempty"`
}

Expand Down
30 changes: 30 additions & 0 deletions bitbucket/resource_hook_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package bitbucket

import (
"encoding/json"
"fmt"
"net/url"
"os"
"strings"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
uuid "github.com/satori/go.uuid"
)

func TestAccBitbucketHook_basic(t *testing.T) {
Expand Down Expand Up @@ -46,6 +49,33 @@ func TestAccBitbucketHook_basic(t *testing.T) {
})
}

func TestEncodesJsonCompletely(t *testing.T) {
hook := &Hook{
UUID: uuid.NewV4().String(),
URL: "https://site.internal/",
Description: "Test description",
Active: false,
Events: []string{
"pullrequests:updated",
},
SkipCertVerification: false,
}

payload, err := json.Marshal(hook)
if err != nil {
t.Logf("Failed to encode hook, %s\n", err)
t.FailNow() // Can't continue test.
}

if !strings.Contains(string(payload), `"active":false`) {
t.Error("Did not render active.")
}

if !strings.Contains(string(payload), `"skip_cert_verification":false`) {
t.Error("Did not render skip_cert_verification.")
}
}

func testAccCheckBitbucketHookDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*Client)
rs, ok := s.RootModule().Resources["bitbucket_hook.test_repo_hook"]
Expand Down

0 comments on commit eabec0c

Please sign in to comment.