From b6c9b2dc7abde5ed00d3836477dae94bfe6202f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 17 May 2017 18:20:47 +0200 Subject: [PATCH] Test members --- .../resource_rancher_environment_test.go | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/builtin/providers/rancher/resource_rancher_environment_test.go b/builtin/providers/rancher/resource_rancher_environment_test.go index ec8a81d7c..6474efaf6 100644 --- a/builtin/providers/rancher/resource_rancher_environment_test.go +++ b/builtin/providers/rancher/resource_rancher_environment_test.go @@ -60,6 +60,38 @@ func TestAccRancherEnvironment_disappears(t *testing.T) { }) } +func TestAccRancherEnvironment_members(t *testing.T) { + var environment rancherClient.Project + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckRancherEnvironmentDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccRancherEnvironmentMembersConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckRancherEnvironmentExists("rancher_environment.foo", &environment), + resource.TestCheckResourceAttr("rancher_environment.foo", "name", "foo"), + resource.TestCheckResourceAttr("rancher_environment.foo", "description", "Terraform acc test group"), + resource.TestCheckResourceAttr("rancher_environment.foo", "orchestration", "cattle"), + resource.TestCheckResourceAttr("rancher_environment.foo", "member.#", "2"), + ), + }, + resource.TestStep{ + Config: testAccRancherEnvironmentMembersUpdateConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckRancherEnvironmentExists("rancher_environment.foo", &environment), + resource.TestCheckResourceAttr("rancher_environment.foo", "name", "foo2"), + resource.TestCheckResourceAttr("rancher_environment.foo", "description", "Terraform acc test group - updated"), + resource.TestCheckResourceAttr("rancher_environment.foo", "orchestration", "swarm"), + resource.TestCheckResourceAttr("rancher_environment.foo", "member.#", "1"), + ), + }, + }, + }) +} + func testAccRancherEnvironmentDisappears(env *rancherClient.Project) resource.TestCheckFunc { return func(s *terraform.State) error { client, err := testAccProvider.Meta().(*Config).GlobalClient() @@ -159,3 +191,37 @@ resource "rancher_environment" "foo" { orchestration = "swarm" } ` + +const testAccRancherEnvironmentMembersConfig = ` +resource "rancher_environment" "foo" { + name = "foo" + description = "Terraform acc test group" + orchestration = "cattle" + + member { + external_id = "1234" + external_id_type = "github_user" + role = "owner" + } + + member { + external_id = "8765" + external_id_type = "github_team" + role = "member" + } +} +` + +const testAccRancherEnvironmentMembersUpdateConfig = ` +resource "rancher_environment" "foo" { + name = "foo" + description = "Terraform acc test group" + orchestration = "cattle" + + member { + external_id = "1235" + external_id_type = "github_user" + role = "owner" + } +} +`