-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(organization_user): expect error (#1535)
- Loading branch information
Showing
1 changed file
with
3 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ package organization_test | |
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/aiven/aiven-go-client/v2" | ||
|
@@ -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{ | ||
|
@@ -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.*", | ||
), | ||
}, | ||
}, | ||
|
@@ -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 | ||
} | ||
} |