Skip to content

Commit

Permalink
provider/rabbitmq: Add test for binding properties_key
Browse files Browse the repository at this point in the history
  • Loading branch information
jtopjian committed Apr 20, 2017
1 parent f5cda34 commit e363c7a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
10 changes: 8 additions & 2 deletions builtin/providers/rabbitmq/acceptance_env/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ sudo rabbitmq-plugins enable rabbitmq_management

sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
sudo chmod +x /usr/local/bin/gimme
gimme 1.6 >> .bashrc
gimme 1.8 >> .bashrc

mkdir ~/go
eval "$(/usr/local/bin/gimme 1.6)"
eval "$(/usr/local/bin/gimme 1.8)"
echo 'export GOPATH=$HOME/go' >> .bashrc
export GOPATH=$HOME/go

Expand All @@ -24,3 +24,9 @@ source .bashrc

go get -u github.com/kardianos/govendor
go get github.com/hashicorp/terraform

cat <<EOF > ~/rabbitmqrc
export RABBITMQ_ENDPOINT="http://127.0.0.1:15672"
export RABBITMQ_USERNAME="guest"
export RABBITMQ_PASSWORD="guest"
EOF
63 changes: 62 additions & 1 deletion builtin/providers/rabbitmq/resource_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccBinding(t *testing.T) {
func TestAccBinding_basic(t *testing.T) {
var bindingInfo rabbithole.BindingInfo
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -28,6 +28,23 @@ func TestAccBinding(t *testing.T) {
})
}

func TestAccBinding_propertiesKey(t *testing.T) {
var bindingInfo rabbithole.BindingInfo
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccBindingCheckDestroy(bindingInfo),
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccBindingConfig_propertiesKey,
Check: testAccBindingCheck(
"rabbitmq_binding.test", &bindingInfo,
),
},
},
})
}

func testAccBindingCheck(rn string, bindingInfo *rabbithole.BindingInfo) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[rn]
Expand Down Expand Up @@ -119,3 +136,47 @@ resource "rabbitmq_binding" "test" {
routing_key = "#"
properties_key = "%23"
}`

const testAccBindingConfig_propertiesKey = `
resource "rabbitmq_vhost" "test" {
name = "test"
}
resource "rabbitmq_permissions" "guest" {
user = "guest"
vhost = "${rabbitmq_vhost.test.name}"
permissions {
configure = ".*"
write = ".*"
read = ".*"
}
}
resource "rabbitmq_exchange" "test" {
name = "Test"
vhost = "${rabbitmq_permissions.guest.vhost}"
settings {
type = "topic"
durable = true
auto_delete = false
}
}
resource "rabbitmq_queue" "test" {
name = "Test.Queue"
vhost = "${rabbitmq_permissions.guest.vhost}"
settings {
durable = true
auto_delete = false
}
}
resource "rabbitmq_binding" "test" {
source = "${rabbitmq_exchange.test.name}"
vhost = "${rabbitmq_vhost.test.name}"
destination = "${rabbitmq_queue.test.name}"
destination_type = "queue"
routing_key = "ANYTHING.#"
properties_key = "ANYTHING.%23"
}
`

0 comments on commit e363c7a

Please sign in to comment.