Skip to content

Commit 5148a56

Browse files
authored
chore: Reuses project in tests - project (#2078)
* 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
1 parent abcb609 commit 5148a56

File tree

6 files changed

+257
-576
lines changed

6 files changed

+257
-576
lines changed
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
package provider_test
22

33
import (
4+
"fmt"
45
"os"
56
"testing"
67

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

1212
func TestAccSTSAssumeRole_basic(t *testing.T) {
1313
var (
1414
resourceName = "mongodbatlas_project.test"
15-
projectName = acc.RandomProjectName()
1615
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
17-
clusterCount = "0"
16+
projectName = acc.RandomProjectName()
1817
)
1918
resource.ParallelTest(t, resource.TestCase{
2019
PreCheck: func() { acc.PreCheckSTSAssumeRole(t); acc.PreCheckRegularCredsAreEmpty(t) },
2120
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
2221
CheckDestroy: acc.CheckDestroyProject,
2322
Steps: []resource.TestStep{
2423
{
25-
Config: acc.ConfigProject(projectName, orgID,
26-
[]*admin.TeamRole{},
27-
),
24+
Config: configProject(orgID, projectName),
2825
Check: resource.ComposeTestCheckFunc(
29-
resource.TestCheckResourceAttr(resourceName, "name", projectName),
3026
resource.TestCheckResourceAttr(resourceName, "org_id", orgID),
31-
resource.TestCheckResourceAttr(resourceName, "cluster_count", clusterCount),
27+
resource.TestCheckResourceAttr(resourceName, "name", projectName),
28+
resource.TestCheckResourceAttr(resourceName, "cluster_count", "0"),
3229
resource.TestCheckResourceAttr(resourceName, "teams.#", "0"),
3330
),
3431
},
@@ -42,3 +39,12 @@ func TestAccSTSAssumeRole_basic(t *testing.T) {
4239
},
4340
})
4441
}
42+
43+
func configProject(orgID, projectName string) string {
44+
return fmt.Sprintf(`
45+
resource "mongodbatlas_project" "test" {
46+
org_id = %[1]q
47+
name = %[2]q
48+
}
49+
`, orgID, projectName)
50+
}

internal/service/project/data_source_project_test.go

Lines changed: 0 additions & 161 deletions
This file was deleted.

internal/service/project/data_source_projects_test.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)