Skip to content

Commit

Permalink
test(account): fix filing team tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel committed Oct 23, 2023
1 parent f64aa9b commit 20ad53a
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
PKG: ${{matrix.pkg}}

sweep:
Expand Down Expand Up @@ -106,4 +107,4 @@ jobs:
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}

AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"log"
"math/big"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -133,6 +134,10 @@ func TestAccAivenAccountAuthentication_saml_invalid_certificate(t *testing.T) {
}

func TestAccAivenAccountAuthentication_auto_join_team_id(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

resourceName := "aiven_account_authentication.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand Down Expand Up @@ -177,19 +182,21 @@ data "aiven_account_authentication" "auth" {
}

func testAccAccountAuthenticationWithAutoJoinTeamIDResource(name string) string {
orgName := os.Getenv("AIVEN_ORGANIZATION_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}
resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}
resource "aiven_account_authentication" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-auth-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-auth-%[2]s"
type = "saml"
enabled = false
auto_join_team_id = aiven_account_team.foo.team_id
Expand All @@ -207,7 +214,7 @@ data "aiven_account_authentication" "auth" {
name = aiven_account_authentication.foo.name
depends_on = [aiven_account_authentication.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountAuthenticationResourceDestroy(s *terraform.State) error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package account_test

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand All @@ -10,6 +11,10 @@ import (
)

func TestAccAivenAccountTeamDataSource_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

datasourceName := "data.aiven_account_team.team"
resourceName := "aiven_account_team.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package account_test

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand All @@ -10,6 +11,10 @@ import (
)

func TestAccAivenAccountTeamMemberDataSource_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

datasourceName := "data.aiven_account_team_member.member"
resourceName := "aiven_account_team_member.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down
19 changes: 13 additions & 6 deletions internal/sdkprovider/service/account/account_team_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

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

func TestAccAivenAccountTeamMember_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team_member.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -37,20 +42,22 @@ func TestAccAivenAccountTeamMember_basic(t *testing.T) {
}

func testAccAccountTeamMemberResource(name string) string {
orgName := os.Getenv("AIVEN_ORGANIZATION_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}
resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}
resource "aiven_account_team_member" "foo" {
team_id = aiven_account_team.foo.team_id
account_id = aiven_account_team.foo.account_id
user_email = "ivan.savciuc+%[email protected]"
user_email = "ivan.savciuc+%[2][email protected]"
}
data "aiven_account_team_member" "member" {
Expand All @@ -59,7 +66,7 @@ data "aiven_account_team_member" "member" {
user_email = aiven_account_team_member.foo.user_email
depends_on = [aiven_account_team_member.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamMemberResourceDestroy(s *terraform.State) error {
Expand Down
21 changes: 14 additions & 7 deletions internal/sdkprovider/service/account/account_team_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

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

func TestAccAivenAccountTeamProject_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team_project.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -37,23 +42,25 @@ func TestAccAivenAccountTeamProject_basic(t *testing.T) {
}

func testAccAccountTeamProjectResource(name string) string {
orgName := os.Getenv("AIVEN_ORGANIZATION_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%[1]s"
}
resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
name = "test-acc-team-%s"
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%[2]s"
}
resource "aiven_project" "foo" {
project = "test-acc-pr-%s"
project = "test-acc-pr-%[2]s"
account_id = aiven_account_team.foo.account_id
}
resource "aiven_account_team_project" "foo" {
account_id = aiven_account.foo.account_id
account_id = data.aiven_account.foo.account_id
team_id = aiven_account_team.foo.team_id
project_name = aiven_project.foo.project
team_type = "admin"
Expand All @@ -65,7 +72,7 @@ data "aiven_account_team_project" "project" {
project_name = aiven_account_team_project.foo.project_name
depends_on = [aiven_account_team_project.foo]
}`, name, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamProjectResourceDestroy(s *terraform.State) error {
Expand Down
15 changes: 11 additions & 4 deletions internal/sdkprovider/service/account/account_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"os"
"testing"

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

func TestAccAivenAccountTeam_basic(t *testing.T) {
if _, ok := os.LookupEnv("AIVEN_ORGANIZATION_NAME"); !ok {
t.Skip("AIVEN_ORGANIZATION_NAME env variable is required to run this test")
}

resourceName := "aiven_account_team.foo"
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

Expand All @@ -36,13 +41,15 @@ func TestAccAivenAccountTeam_basic(t *testing.T) {
}

func testAccAccountTeamResource(name string) string {
orgName := os.Getenv("AIVEN_ORGANIZATION_NAME")

return fmt.Sprintf(`
resource "aiven_account" "foo" {
name = "test-acc-ac-%s"
data "aiven_account" "foo" {
name = "%s"
}
resource "aiven_account_team" "foo" {
account_id = aiven_account.foo.account_id
account_id = data.aiven_account.foo.account_id
name = "test-acc-team-%s"
}
Expand All @@ -51,7 +58,7 @@ data "aiven_account_team" "team" {
account_id = aiven_account_team.foo.account_id
depends_on = [aiven_account_team.foo]
}`, name, name)
}`, orgName, name)
}

func testAccCheckAivenAccountTeamResourceDestroy(s *terraform.State) error {
Expand Down

0 comments on commit 20ad53a

Please sign in to comment.