Skip to content

Commit f71ec97

Browse files
committed
feat: add test
1 parent fe0a568 commit f71ec97

File tree

4 files changed

+62
-7
lines changed

4 files changed

+62
-7
lines changed

internal/services/rdb/instance.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ func ResourceRdbInstanceCreate(ctx context.Context, d *schema.ResourceData, m in
336336
if err != nil {
337337
return diag.FromErr(err)
338338
}
339-
ID := ""
339+
id := ""
340+
340341
if regionalSnapshotID, ok := d.GetOk("snapshot_id"); ok {
341342
haCluster := d.Get("is_ha_cluster").(bool)
342343
nodeType := d.Get("node_type").(string)
@@ -374,7 +375,7 @@ func ResourceRdbInstanceCreate(ctx context.Context, d *schema.ResourceData, m in
374375
}
375376
}
376377
d.SetId(regional.NewIDString(region, res.ID))
377-
ID = res.ID
378+
id = res.ID
378379

379380
} else {
380381

@@ -432,13 +433,13 @@ func ResourceRdbInstanceCreate(ctx context.Context, d *schema.ResourceData, m in
432433
}
433434

434435
d.SetId(regional.NewIDString(region, res.ID))
435-
ID = res.ID
436+
id = res.ID
436437
}
437438

438439
mustUpdate := false
439440
updateReq := &rdb.UpdateInstanceRequest{
440441
Region: region,
441-
InstanceID: ID,
442+
InstanceID: id,
442443
}
443444
// Configure Schedule Backup
444445
// BackupScheduleFrequency and BackupScheduleRetention can only configure after instance creation
@@ -460,7 +461,7 @@ func ResourceRdbInstanceCreate(ctx context.Context, d *schema.ResourceData, m in
460461
mustUpdate = true
461462
}
462463
if mustUpdate {
463-
_, err = waitForRDBInstance(ctx, rdbAPI, region, ID, d.Timeout(schema.TimeoutCreate))
464+
_, err = waitForRDBInstance(ctx, rdbAPI, region, id, d.Timeout(schema.TimeoutCreate))
464465
if err != nil {
465466
return diag.FromErr(err)
466467
}
@@ -471,7 +472,7 @@ func ResourceRdbInstanceCreate(ctx context.Context, d *schema.ResourceData, m in
471472
}
472473
// Configure Instance settings
473474
if settings, ok := d.GetOk("settings"); ok {
474-
res, err := waitForRDBInstance(ctx, rdbAPI, region, ID, d.Timeout(schema.TimeoutCreate))
475+
res, err := waitForRDBInstance(ctx, rdbAPI, region, id, d.Timeout(schema.TimeoutCreate))
475476
if err != nil {
476477
return diag.FromErr(err)
477478
}

internal/services/rdb/instance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ func TestAccInstance_UpdateEncryptionAtRest(t *testing.T) {
13831383
})
13841384
}
13851385

1386-
func TestAccInstance_CompleteWorkflow(t *testing.T) {
1386+
func TestAccRdbInstance_CompleteWorkflow(t *testing.T) {
13871387
tt := acctest.NewTestTools(t)
13881388
defer tt.Cleanup()
13891389

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
version: 2
3+
interactions:
4+
- id: 0
5+
request:
6+
proto: HTTP/1.1
7+
proto_major: 1
8+
proto_minor: 1
9+
content_length: 395
10+
transfer_encoding: []
11+
trailer: {}
12+
host: api.scaleway.com
13+
remote_addr: ""
14+
request_uri: ""
15+
body: '{"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","name":"test-rdb-case-sensitive","engine":"POSTGRESQL15","user_name":"my_initial_user","password":"thiZ_is_v\u0026ry_s3cret","node_type":"db-dev-s","is_ha_cluster":false,"disable_backup":true,"tags":null,"init_settings":null,"volume_type":"lssd","volume_size":0,"init_endpoints":null,"backup_same_region":false,"encryption":{"enabled":false}}'
16+
form: {}
17+
headers:
18+
Content-Type:
19+
- application/json
20+
User-Agent:
21+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.0; darwin; amd64) terraform-provider/develop terraform/terraform-tests
22+
url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances
23+
method: POST
24+
response:
25+
proto: HTTP/2.0
26+
proto_major: 2
27+
proto_minor: 0
28+
transfer_encoding: []
29+
trailer: {}
30+
content_length: 183
31+
uncompressed: false
32+
body: '{"details":[{"argument_name":"engine","help_message":"engine must contains engine name and version","reason":"constraint"}],"message":"invalid argument(s)","type":"invalid_arguments"}'
33+
headers:
34+
Content-Length:
35+
- "183"
36+
Content-Security-Policy:
37+
- default-src 'none'; frame-ancestors 'none'
38+
Content-Type:
39+
- application/json
40+
Date:
41+
- Mon, 02 Sep 2024 11:35:10 GMT
42+
Server:
43+
- Scaleway API Gateway (fr-par-1;edge01)
44+
Strict-Transport-Security:
45+
- max-age=63072000
46+
X-Content-Type-Options:
47+
- nosniff
48+
X-Frame-Options:
49+
- DENY
50+
X-Request-Id:
51+
- bdf3376f-cf30-46db-9cd4-f144998a7e8f
52+
status: 400 Bad Request
53+
code: 400
54+
duration: 63.214902ms

log

Whitespace-only changes.

0 commit comments

Comments
 (0)