Skip to content

Commit

Permalink
chore: Reuses project in tests - project (#2078)
Browse files Browse the repository at this point in the history
* move ds tests to resource

* move plural ds

* move acc.ConfigProject to project resourfce

* rename test names

* remove CheckProjectAttributes

* checkExists

* TestAccSTSAssumeRole_basic

* TestAccSTSAssumeRole_basic

* local helper methods

* mig.TestStepCheckEmptyPlan

* join TestAccProject_withProjectOwner with basic test

* refactor checks

* add limit tests for data source
  • Loading branch information
lantoli committed Mar 26, 2024
1 parent abcb609 commit 5148a56
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 576 deletions.
22 changes: 14 additions & 8 deletions internal/provider/provider_authentication_test.go
@@ -1,34 +1,31 @@
package provider_test

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115008/admin"
)

func TestAccSTSAssumeRole_basic(t *testing.T) {
var (
resourceName = "mongodbatlas_project.test"
projectName = acc.RandomProjectName()
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
clusterCount = "0"
projectName = acc.RandomProjectName()
)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckSTSAssumeRole(t); acc.PreCheckRegularCredsAreEmpty(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyProject,
Steps: []resource.TestStep{
{
Config: acc.ConfigProject(projectName, orgID,
[]*admin.TeamRole{},
),
Config: configProject(orgID, projectName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", projectName),
resource.TestCheckResourceAttr(resourceName, "org_id", orgID),
resource.TestCheckResourceAttr(resourceName, "cluster_count", clusterCount),
resource.TestCheckResourceAttr(resourceName, "name", projectName),
resource.TestCheckResourceAttr(resourceName, "cluster_count", "0"),
resource.TestCheckResourceAttr(resourceName, "teams.#", "0"),
),
},
Expand All @@ -42,3 +39,12 @@ func TestAccSTSAssumeRole_basic(t *testing.T) {
},
})
}

func configProject(orgID, projectName string) string {
return fmt.Sprintf(`
resource "mongodbatlas_project" "test" {
org_id = %[1]q
name = %[2]q
}
`, orgID, projectName)
}
161 changes: 0 additions & 161 deletions internal/service/project/data_source_project_test.go

This file was deleted.

103 changes: 0 additions & 103 deletions internal/service/project/data_source_projects_test.go

This file was deleted.

0 comments on commit 5148a56

Please sign in to comment.