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

Removed omitempty, as it caused HTTP 400s when bools were false. #49

Merged
merged 1 commit into from
Aug 31, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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