Skip to content

Commit ae8b809

Browse files
committed
add tests
1 parent 74acf21 commit ae8b809

File tree

7 files changed

+218
-155
lines changed

7 files changed

+218
-155
lines changed

docs/resources/vpc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The following arguments are supported:
3636
- `name` - (Optional) The name for the VPC. If not provided it will be randomly generated.
3737
- `tags` - (Optional) The tags to associate with the VPC.
3838
- `enable_routing` - (Optional) Enable routing between Private Networks in the VPC. Note that you will not be able to deactivate it afterwards.
39-
- `enable_custom_routes_propagation` - (Optional) Defines whether the VPC advertises custom routes between its Private Networks. Note that you will not be able to deactivate it afterwards.
39+
- `enable_custom_routes_propagation` - (`true` for newly created VPCs) Defines whether the VPC advertises custom routes between its Private Networks. Note that you will not be able to deactivate it afterwards.
4040
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) of the VPC.
4141
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the VPC is associated with.
4242

internal/services/vpc/private_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func ResourcePrivateNetwork() *schema.Resource {
159159
ForceNew: true,
160160
Description: "The VPC in which to create the private network",
161161
},
162-
"default_route_propagation_enabled": {
162+
"enable_default_route_propagation": {
163163
Type: schema.TypeBool,
164164
Optional: true,
165165
Computed: true,

internal/services/vpc/private_network_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ func TestAccVPCPrivateNetwork_Basic(t *testing.T) {
4343
"region",
4444
"fr-par",
4545
),
46+
resource.TestCheckResourceAttr(
47+
"scaleway_vpc_private_network.pn01",
48+
"enable_default_route_propagation",
49+
"false",
50+
),
4651
),
4752
},
4853
{
4954
Config: fmt.Sprintf(`
5055
resource scaleway_vpc_private_network pn01 {
51-
name = "%s"
52-
tags = ["tag0", "tag1"]
56+
name = "%s"
57+
tags = ["tag0", "tag1"]
58+
enable_default_route_propagation = true
5359
}
5460
`, privateNetworkName),
5561
Check: resource.ComposeTestCheckFunc(
@@ -67,6 +73,11 @@ func TestAccVPCPrivateNetwork_Basic(t *testing.T) {
6773
"tags.1",
6874
"tag1",
6975
),
76+
resource.TestCheckResourceAttr(
77+
"scaleway_vpc_private_network.pn01",
78+
"enable_default_route_propagation",
79+
"true",
80+
),
7081
),
7182
},
7283
},

internal/services/vpc/testdata/vpc-basic.cassette.yaml

Lines changed: 104 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ interactions:
1212
host: api.scaleway.com
1313
remote_addr: ""
1414
request_uri: ""
15-
body: '{"name":"test-vpc","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","tags":[],"enable_routing":false}'
15+
body: '{"name":"test-vpc","project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","tags":[],"enable_routing":false}'
1616
form: {}
1717
headers:
1818
Content-Type:
1919
- application/json
2020
User-Agent:
21-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
21+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
2222
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs
2323
method: POST
2424
response:
@@ -27,80 +27,82 @@ interactions:
2727
proto_minor: 0
2828
transfer_encoding: []
2929
trailer: {}
30-
content_length: 364
30+
content_length: 396
3131
uncompressed: false
32-
body: '{"created_at":"2025-01-28T10:05:15.946341Z","id":"01e9de51-1156-4ace-9b02-8048eb21ce68","is_default":false,"name":"test-vpc","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","private_network_count":0,"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-01-28T10:05:15.946341Z"}'
32+
body: '{"created_at":"2025-06-30T14:35:34.670387Z","custom_routes_propagation_enabled":false,"id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","is_default":false,"name":"test-vpc","organization_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","private_network_count":0,"project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-06-30T14:35:34.670387Z"}'
3333
headers:
3434
Content-Length:
35-
- "364"
35+
- "396"
3636
Content-Security-Policy:
3737
- default-src 'none'; frame-ancestors 'none'
3838
Content-Type:
3939
- application/json
4040
Date:
41-
- Tue, 28 Jan 2025 10:05:15 GMT
41+
- Mon, 30 Jun 2025 14:35:34 GMT
4242
Server:
43-
- Scaleway API Gateway (fr-par-1;edge02)
43+
- Scaleway API Gateway (fr-par-2;edge03)
4444
Strict-Transport-Security:
4545
- max-age=63072000
4646
X-Content-Type-Options:
4747
- nosniff
4848
X-Frame-Options:
4949
- DENY
5050
X-Request-Id:
51-
- e13796ae-45a3-40e5-8e9d-b4af2e3b710e
51+
- 4f04f91d-97ab-469c-b188-6b76ee3eccd0
5252
status: 200 OK
5353
code: 200
54-
duration: 414.722792ms
54+
duration: 536.625333ms
5555
- id: 1
5656
request:
5757
proto: HTTP/1.1
5858
proto_major: 1
5959
proto_minor: 1
60-
content_length: 0
60+
content_length: 2
6161
transfer_encoding: []
6262
trailer: {}
6363
host: api.scaleway.com
6464
remote_addr: ""
6565
request_uri: ""
66-
body: ""
66+
body: '{}'
6767
form: {}
6868
headers:
69+
Content-Type:
70+
- application/json
6971
User-Agent:
70-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
71-
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/01e9de51-1156-4ace-9b02-8048eb21ce68
72-
method: GET
72+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
73+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934/enable-custom-routes-propagation
74+
method: POST
7375
response:
7476
proto: HTTP/2.0
7577
proto_major: 2
7678
proto_minor: 0
7779
transfer_encoding: []
7880
trailer: {}
79-
content_length: 354
81+
content_length: 395
8082
uncompressed: false
81-
body: '{"created_at":"2025-01-28T10:05:15.946341Z","id":"01e9de51-1156-4ace-9b02-8048eb21ce68","is_default":false,"name":"test-vpc","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","private_network_count":0,"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-01-28T10:05:15.946341Z"}'
83+
body: '{"created_at":"2025-06-30T14:35:34.670387Z","custom_routes_propagation_enabled":true,"id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","is_default":false,"name":"test-vpc","organization_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","private_network_count":0,"project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-06-30T14:35:34.769793Z"}'
8284
headers:
8385
Content-Length:
84-
- "354"
86+
- "395"
8587
Content-Security-Policy:
8688
- default-src 'none'; frame-ancestors 'none'
8789
Content-Type:
8890
- application/json
8991
Date:
90-
- Tue, 28 Jan 2025 10:05:15 GMT
92+
- Mon, 30 Jun 2025 14:35:34 GMT
9193
Server:
92-
- Scaleway API Gateway (fr-par-1;edge02)
94+
- Scaleway API Gateway (fr-par-2;edge03)
9395
Strict-Transport-Security:
9496
- max-age=63072000
9597
X-Content-Type-Options:
9698
- nosniff
9799
X-Frame-Options:
98100
- DENY
99101
X-Request-Id:
100-
- 549403ec-acf6-4688-b88b-ab23d59d1746
102+
- f6bb917f-493a-47b9-b349-7831deac1278
101103
status: 200 OK
102104
code: 200
103-
duration: 30.044958ms
105+
duration: 85.197834ms
104106
- id: 2
105107
request:
106108
proto: HTTP/1.1
@@ -116,40 +118,40 @@ interactions:
116118
form: {}
117119
headers:
118120
User-Agent:
119-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
120-
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/01e9de51-1156-4ace-9b02-8048eb21ce68
121+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
122+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934
121123
method: GET
122124
response:
123125
proto: HTTP/2.0
124126
proto_major: 2
125127
proto_minor: 0
126128
transfer_encoding: []
127129
trailer: {}
128-
content_length: 364
130+
content_length: 395
129131
uncompressed: false
130-
body: '{"created_at":"2025-01-28T10:05:15.946341Z","id":"01e9de51-1156-4ace-9b02-8048eb21ce68","is_default":false,"name":"test-vpc","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","private_network_count":0,"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-01-28T10:05:15.946341Z"}'
132+
body: '{"created_at":"2025-06-30T14:35:34.670387Z","custom_routes_propagation_enabled":true,"id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","is_default":false,"name":"test-vpc","organization_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","private_network_count":0,"project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-06-30T14:35:34.769793Z"}'
131133
headers:
132134
Content-Length:
133-
- "364"
135+
- "395"
134136
Content-Security-Policy:
135137
- default-src 'none'; frame-ancestors 'none'
136138
Content-Type:
137139
- application/json
138140
Date:
139-
- Tue, 28 Jan 2025 10:05:16 GMT
141+
- Mon, 30 Jun 2025 14:35:34 GMT
140142
Server:
141-
- Scaleway API Gateway (fr-par-1;edge02)
143+
- Scaleway API Gateway (fr-par-2;edge03)
142144
Strict-Transport-Security:
143145
- max-age=63072000
144146
X-Content-Type-Options:
145147
- nosniff
146148
X-Frame-Options:
147149
- DENY
148150
X-Request-Id:
149-
- c3710d8b-c85f-4598-b064-007be4d16610
151+
- 6f98d75e-5678-46f5-b9e9-d8e72df9432d
150152
status: 200 OK
151153
code: 200
152-
duration: 30.106083ms
154+
duration: 53.833917ms
153155
- id: 3
154156
request:
155157
proto: HTTP/1.1
@@ -165,40 +167,40 @@ interactions:
165167
form: {}
166168
headers:
167169
User-Agent:
168-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
169-
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/01e9de51-1156-4ace-9b02-8048eb21ce68
170+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
171+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934
170172
method: GET
171173
response:
172174
proto: HTTP/2.0
173175
proto_major: 2
174176
proto_minor: 0
175177
transfer_encoding: []
176178
trailer: {}
177-
content_length: 364
179+
content_length: 395
178180
uncompressed: false
179-
body: '{"created_at":"2025-01-28T10:05:15.946341Z","id":"01e9de51-1156-4ace-9b02-8048eb21ce68","is_default":false,"name":"test-vpc","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","private_network_count":0,"project_id":"105bdce1-64c0-48ab-899d-868455867ecf","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-01-28T10:05:15.946341Z"}'
181+
body: '{"created_at":"2025-06-30T14:35:34.670387Z","custom_routes_propagation_enabled":true,"id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","is_default":false,"name":"test-vpc","organization_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","private_network_count":0,"project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-06-30T14:35:34.769793Z"}'
180182
headers:
181183
Content-Length:
182-
- "364"
184+
- "395"
183185
Content-Security-Policy:
184186
- default-src 'none'; frame-ancestors 'none'
185187
Content-Type:
186188
- application/json
187189
Date:
188-
- Tue, 28 Jan 2025 10:05:17 GMT
190+
- Mon, 30 Jun 2025 14:35:34 GMT
189191
Server:
190-
- Scaleway API Gateway (fr-par-1;edge02)
192+
- Scaleway API Gateway (fr-par-2;edge03)
191193
Strict-Transport-Security:
192194
- max-age=63072000
193195
X-Content-Type-Options:
194196
- nosniff
195197
X-Frame-Options:
196198
- DENY
197199
X-Request-Id:
198-
- 9734e596-fee9-4111-b7e7-90b65d26ea5d
200+
- f92f8a4c-7471-4a2c-ac9a-10184e5f1c0d
199201
status: 200 OK
200202
code: 200
201-
duration: 38.359416ms
203+
duration: 53.938875ms
202204
- id: 4
203205
request:
204206
proto: HTTP/1.1
@@ -214,8 +216,57 @@ interactions:
214216
form: {}
215217
headers:
216218
User-Agent:
217-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
218-
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/01e9de51-1156-4ace-9b02-8048eb21ce68
219+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
220+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934
221+
method: GET
222+
response:
223+
proto: HTTP/2.0
224+
proto_major: 2
225+
proto_minor: 0
226+
transfer_encoding: []
227+
trailer: {}
228+
content_length: 395
229+
uncompressed: false
230+
body: '{"created_at":"2025-06-30T14:35:34.670387Z","custom_routes_propagation_enabled":true,"id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","is_default":false,"name":"test-vpc","organization_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","private_network_count":0,"project_id":"564aa517-68b0-4fd7-8c8c-d21c4bcdcbd5","region":"fr-par","routing_enabled":true,"tags":[],"updated_at":"2025-06-30T14:35:34.769793Z"}'
231+
headers:
232+
Content-Length:
233+
- "395"
234+
Content-Security-Policy:
235+
- default-src 'none'; frame-ancestors 'none'
236+
Content-Type:
237+
- application/json
238+
Date:
239+
- Mon, 30 Jun 2025 14:35:35 GMT
240+
Server:
241+
- Scaleway API Gateway (fr-par-2;edge03)
242+
Strict-Transport-Security:
243+
- max-age=63072000
244+
X-Content-Type-Options:
245+
- nosniff
246+
X-Frame-Options:
247+
- DENY
248+
X-Request-Id:
249+
- 90ba7bae-3637-49f0-a701-711503be697a
250+
status: 200 OK
251+
code: 200
252+
duration: 54.986333ms
253+
- id: 5
254+
request:
255+
proto: HTTP/1.1
256+
proto_major: 1
257+
proto_minor: 1
258+
content_length: 0
259+
transfer_encoding: []
260+
trailer: {}
261+
host: api.scaleway.com
262+
remote_addr: ""
263+
request_uri: ""
264+
body: ""
265+
form: {}
266+
headers:
267+
User-Agent:
268+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
269+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934
219270
method: DELETE
220271
response:
221272
proto: HTTP/2.0
@@ -232,21 +283,21 @@ interactions:
232283
Content-Type:
233284
- application/json
234285
Date:
235-
- Tue, 28 Jan 2025 10:05:18 GMT
286+
- Mon, 30 Jun 2025 14:35:35 GMT
236287
Server:
237-
- Scaleway API Gateway (fr-par-1;edge02)
288+
- Scaleway API Gateway (fr-par-2;edge03)
238289
Strict-Transport-Security:
239290
- max-age=63072000
240291
X-Content-Type-Options:
241292
- nosniff
242293
X-Frame-Options:
243294
- DENY
244295
X-Request-Id:
245-
- 73d174bb-7192-4fd3-9814-9f8d34e85c57
296+
- c4b34a41-13d8-4b42-a53b-51fcbb22c1e6
246297
status: 204 No Content
247298
code: 204
248-
duration: 84.8405ms
249-
- id: 5
299+
duration: 128.426209ms
300+
- id: 6
250301
request:
251302
proto: HTTP/1.1
252303
proto_major: 1
@@ -261,8 +312,8 @@ interactions:
261312
form: {}
262313
headers:
263314
User-Agent:
264-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.3; darwin; arm64) terraform-provider/develop terraform/terraform-tests
265-
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/01e9de51-1156-4ace-9b02-8048eb21ce68
315+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.4; darwin; arm64) terraform-provider/develop terraform/terraform-tests
316+
url: https://api.scaleway.com/vpc/v2/regions/fr-par/vpcs/aeacecb1-97ff-4429-a379-ef7faa9f4934
266317
method: GET
267318
response:
268319
proto: HTTP/2.0
@@ -272,7 +323,7 @@ interactions:
272323
trailer: {}
273324
content_length: 124
274325
uncompressed: false
275-
body: '{"message":"resource is not found","resource":"vpc","resource_id":"01e9de51-1156-4ace-9b02-8048eb21ce68","type":"not_found"}'
326+
body: '{"message":"resource is not found","resource":"vpc","resource_id":"aeacecb1-97ff-4429-a379-ef7faa9f4934","type":"not_found"}'
276327
headers:
277328
Content-Length:
278329
- "124"
@@ -281,17 +332,17 @@ interactions:
281332
Content-Type:
282333
- application/json
283334
Date:
284-
- Tue, 28 Jan 2025 10:05:18 GMT
335+
- Mon, 30 Jun 2025 14:35:35 GMT
285336
Server:
286-
- Scaleway API Gateway (fr-par-1;edge02)
337+
- Scaleway API Gateway (fr-par-2;edge03)
287338
Strict-Transport-Security:
288339
- max-age=63072000
289340
X-Content-Type-Options:
290341
- nosniff
291342
X-Frame-Options:
292343
- DENY
293344
X-Request-Id:
294-
- 082adeea-c82d-4663-baa0-9a6519937e1a
345+
- 3c69b9cf-eb33-4e64-973b-af160e9c8c02
295346
status: 404 Not Found
296347
code: 404
297-
duration: 29.944416ms
348+
duration: 29.296ms

0 commit comments

Comments
 (0)