diff --git a/bitbucket/resource_hook.go b/bitbucket/resource_hook.go index 2420f456..5c226dee 100644 --- a/bitbucket/resource_hook.go +++ b/bitbucket/resource_hook.go @@ -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"` } diff --git a/bitbucket/resource_hook_test.go b/bitbucket/resource_hook_test.go index 4f8450ac..f322166e 100644 --- a/bitbucket/resource_hook_test.go +++ b/bitbucket/resource_hook_test.go @@ -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) { @@ -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"]