Skip to content

Commit

Permalink
test(organization_user): expect error (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-held-aiven authored Jan 16, 2024
2 parents 3cc426f + e586751 commit 9aa138b
Showing 1 changed file with 3 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package organization_test
import (
"context"
"fmt"
"log"
"regexp"
"testing"

"github.com/aiven/aiven-go-client/v2"
Expand All @@ -16,7 +16,6 @@ import (
)

func TestAccAivenOrganizationUser_basic(t *testing.T) {
resourceName := "aiven_organization_user.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -26,12 +25,8 @@ func TestAccAivenOrganizationUser_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccOrganizationUserResource(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAivenOrganizationUserAttributes("data.aiven_organization_user.member"),
resource.TestCheckResourceAttr(
resourceName, "user_email", fmt.Sprintf("aleks+%[email protected]", rName),
),
resource.TestCheckResourceAttr(resourceName, "accepted", "false"),
ExpectError: regexp.MustCompile(
"creation of organization user is not supported anymore via Terraform.*",
),
},
},
Expand Down Expand Up @@ -101,34 +96,3 @@ func testAccCheckAivenOrganizationUserResourceDestroy(s *terraform.State) error

return nil
}

func testAccCheckAivenOrganizationUserAttributes(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
r := s.RootModule().Resources[n]
a := r.Primary.Attributes

log.Printf("[DEBUG] organization user attributes %v", a)

if a["organization_id"] == "" {
return fmt.Errorf("expected to get an organization_id from Aiven")
}

if a["user_email"] == "" {
return fmt.Errorf("expected to get a user_email from Aiven")
}

if a["create_time"] == "" {
return fmt.Errorf("expected to get a create_time from Aiven")
}

if a["accepted"] != "false" {
return fmt.Errorf("expected to get a accepted from Aiven")
}

if a["invited_by"] == "" {
return fmt.Errorf("expected to get a invited_by from Aiven")
}

return nil
}
}

0 comments on commit 9aa138b

Please sign in to comment.