6
6
"testing"
7
7
8
8
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
9
10
)
10
11
11
12
func TestAccIntegrationResource (t * testing.T ) {
@@ -17,15 +18,15 @@ func TestAccIntegrationResource(t *testing.T) {
17
18
if deployProfile == "" {
18
19
t .Skip ("AUTOMQ_TEST_DEPLOY_PROFILE must be set for this test" )
19
20
}
20
- endpoint := os .Getenv ("AUTOMQ_TEST_BYOC_ENDPOINT " )
21
+ endpoint := os .Getenv ("AUTOMQ_BYOC_ENDPOINT " )
21
22
if endpoint == "" {
22
- t .Skip ("AUTOMQ_TEST_BYOC_ENDPOINT must be set for this test" )
23
+ t .Skip ("AUTOMQ_BYOC_ENDPOINT must be set for this test" )
23
24
}
24
- accessKeyId := os .Getenv ("AUTOMQ_TEST_BYOC_ACCESS_KEY_ID " )
25
+ accessKeyId := os .Getenv ("AUTOMQ_BYOC_ACCESS_KEY_ID " )
25
26
if accessKeyId == "" {
26
27
t .Skip ("AUTOMQ_TEST_BYOC_ACCESS_KEY_ID must be set for this test" )
27
28
}
28
- secretKey := os .Getenv ("AUTOMQ_TEST_BYOC_SECRET_KEY " )
29
+ secretKey := os .Getenv ("AUTOMQ_BYOC_SECRET_KEY " )
29
30
if secretKey == "" {
30
31
t .Skip ("AUTOMQ_TEST_BYOC_SECRET_KEY must be set for this test" )
31
32
}
@@ -56,6 +57,18 @@ func TestAccIntegrationResource(t *testing.T) {
56
57
ResourceName : "automq_integration.test_prometheus" ,
57
58
ImportState : true ,
58
59
ImportStateVerify : true ,
60
+ ImportStateIdFunc : func (s * terraform.State ) (string , error ) {
61
+ rs , ok := s .RootModule ().Resources ["automq_integration.test_prometheus" ]
62
+ if ! ok {
63
+ return "" , fmt .Errorf ("Not found: %s" , "automq_integration.test_prometheus" )
64
+ }
65
+ id := fmt .Sprintf ("%s@%s" , rs .Primary .Attributes ["environment_id" ], rs .Primary .Attributes ["id" ])
66
+ return id , nil
67
+ },
68
+ ImportStateVerifyIgnore : []string {
69
+ "created_at" ,
70
+ "last_updated" ,
71
+ },
59
72
},
60
73
// Update testing
61
74
{
@@ -147,7 +160,7 @@ resource "automq_integration" "test_cloudwatch" {
147
160
deploy_profile = %[2]q
148
161
name = "test-cloudwatch"
149
162
type = "cloudWatch"
150
- cloudwatch_config {
163
+ cloudwatch_config = {
151
164
namespace = "AutoMQ/Test"
152
165
}
153
166
}
0 commit comments