7
7
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
8
8
)
9
9
10
- func TestAccDataSourceMongoDBInstance_ByName (t * testing.T ) {
10
+ func TestAccDataSourceMongoDBInstance_Both (t * testing.T ) {
11
11
tt := acctest .NewTestTools (t )
12
12
defer tt .Cleanup ()
13
13
@@ -18,59 +18,32 @@ func TestAccDataSourceMongoDBInstance_ByName(t *testing.T) {
18
18
Steps : []resource.TestStep {
19
19
{
20
20
Config : `
21
- resource "scaleway_mongodb_instance" "test" {
22
- name = "test-mongodb-instance-by-name"
23
- version = "7.0"
24
- node_type = "MGDB-PLAY2-NANO"
25
- node_number = 1
26
- user_name = "my_initial_user"
27
- password = "thiZ_is_v&ry_s3cret"
28
- }
29
-
30
- data "scaleway_mongodb_instance" "test_by_name" {
31
- name = scaleway_mongodb_instance.test.name
32
- }
33
- ` ,
34
- Check : resource .ComposeTestCheckFunc (
35
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_name" , "name" , "test-mongodb-instance-by-name" ),
36
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_name" , "version" , "7.0" ),
37
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_name" , "node_type" , "mgdb-play2-nano" ),
38
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_name" , "node_number" , "1" ),
39
- ),
40
- },
41
- },
42
- })
43
- }
44
-
45
- func TestAccDataSourceMongoDBInstance_ByID (t * testing.T ) {
46
- tt := acctest .NewTestTools (t )
47
- defer tt .Cleanup ()
48
-
49
- resource .ParallelTest (t , resource.TestCase {
50
- PreCheck : func () { acctest .PreCheck (t ) },
51
- ProviderFactories : tt .ProviderFactories ,
52
- CheckDestroy : IsInstanceDestroyed (tt ),
53
- Steps : []resource.TestStep {
54
- {
55
- Config : `
56
- resource "scaleway_mongodb_instance" "test" {
57
- name = "test-mongodb-instance-id"
58
- version = "7.0"
59
- node_type = "MGDB-PLAY2-NANO"
60
- node_number = 1
61
- user_name = "my_initial_user"
62
- password = "thiZ_is_v&ry_s3cret"
63
- }
64
-
65
- data "scaleway_mongodb_instance" "test_by_id" {
66
- instance_id = scaleway_mongodb_instance.test.id
67
- }
21
+ resource "scaleway_mongodb_instance" "test" {
22
+ name = "test-mongodb-instance-both"
23
+ version = "7.0"
24
+ node_type = "MGDB-PLAY2-NANO"
25
+ node_number = 1
26
+ user_name = "my_initial_user"
27
+ password = "thiZ_is_v&ry_s3cret"
28
+ }
29
+
30
+ data "scaleway_mongodb_instance" "by_name" {
31
+ name = scaleway_mongodb_instance.test.name
32
+ }
33
+
34
+ data "scaleway_mongodb_instance" "by_id" {
35
+ instance_id = scaleway_mongodb_instance.test.id
36
+ }
68
37
` ,
69
38
Check : resource .ComposeTestCheckFunc (
70
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_id" , "name" , "test-mongodb-instance-id" ),
71
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_id" , "version" , "7.0" ),
72
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_id" , "node_type" , "mgdb-play2-nano" ),
73
- resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.test_by_id" , "node_number" , "1" ),
39
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_name" , "name" , "test-mongodb-instance-both" ),
40
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_name" , "version" , "7.0" ),
41
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_name" , "node_type" , "mgdb-play2-nano" ),
42
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_name" , "node_number" , "1" ),
43
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_id" , "name" , "test-mongodb-instance-both" ),
44
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_id" , "version" , "7.0" ),
45
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_id" , "node_type" , "mgdb-play2-nano" ),
46
+ resource .TestCheckResourceAttr ("data.scaleway_mongodb_instance.by_id" , "node_number" , "1" ),
74
47
),
75
48
},
76
49
},
0 commit comments