Skip to content

Commit 6340fc1

Browse files
committed
move IsServerPresent, IsSnapshotPresent and IsSnapshotDestroyed to checks.go
1 parent 56bcc19 commit 6340fc1

File tree

6 files changed

+164
-168
lines changed

6 files changed

+164
-168
lines changed

internal/services/instance/image_test.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestAccImage_BlockVolume(t *testing.T) {
2525
ProtoV6ProviderFactories: tt.ProviderFactories,
2626
CheckDestroy: resource.ComposeTestCheckFunc(
2727
isImageDestroyed(tt),
28-
isSnapshotDestroyed(tt),
28+
instancechecks.IsSnapshotDestroyed(tt),
2929
instancechecks.IsVolumeDestroyed(tt),
3030
),
3131
Steps: []resource.TestStep{
@@ -51,7 +51,7 @@ func TestAccImage_BlockVolume(t *testing.T) {
5151
`,
5252
Check: resource.ComposeTestCheckFunc(
5353
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.main"),
54-
isSnapshotPresent(tt, "scaleway_instance_snapshot.main"),
54+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.main"),
5555
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
5656
resource.TestCheckResourceAttr("scaleway_instance_image.main", "name", "test_image_basic"),
5757
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.main", "id"),
@@ -93,7 +93,7 @@ func TestAccImage_BlockVolume(t *testing.T) {
9393
`,
9494
Check: resource.ComposeTestCheckFunc(
9595
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.main"),
96-
isSnapshotPresent(tt, "scaleway_instance_snapshot.main"),
96+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.main"),
9797
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
9898
resource.TestCheckResourceAttr("scaleway_instance_image.main", "name", "test_image_renamed"),
9999
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.main", "id"),
@@ -121,7 +121,7 @@ func TestAccImage_ExternalBlockVolume(t *testing.T) {
121121
ProtoV6ProviderFactories: tt.ProviderFactories,
122122
CheckDestroy: resource.ComposeTestCheckFunc(
123123
isImageDestroyed(tt),
124-
isSnapshotDestroyed(tt),
124+
instancechecks.IsSnapshotDestroyed(tt),
125125
instancechecks.IsVolumeDestroyed(tt),
126126
),
127127
Steps: []resource.TestStep{
@@ -240,7 +240,7 @@ func TestAccImage_Server(t *testing.T) {
240240
}
241241
`,
242242
Check: resource.ComposeTestCheckFunc(
243-
isServerPresent(tt, "scaleway_instance_server.main"),
243+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.main"),
244244
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.main"),
245245
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
246246
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_block_snapshot.main", "id"),
@@ -267,7 +267,7 @@ func TestAccImage_Server(t *testing.T) {
267267
}
268268
`,
269269
Check: resource.ComposeTestCheckFunc(
270-
isServerPresent(tt, "scaleway_instance_server.main"),
270+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.main"),
271271
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.main"),
272272
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
273273
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_block_snapshot.main", "id"),
@@ -293,7 +293,7 @@ func TestAccImage_ServerWithBlockVolume(t *testing.T) {
293293
ProtoV6ProviderFactories: tt.ProviderFactories,
294294
CheckDestroy: resource.ComposeTestCheckFunc(
295295
isImageDestroyed(tt),
296-
isSnapshotDestroyed(tt),
296+
instancechecks.IsSnapshotDestroyed(tt),
297297
instancechecks.IsVolumeDestroyed(tt),
298298
instancechecks.IsServerDestroyed(tt),
299299
),
@@ -319,8 +319,8 @@ func TestAccImage_ServerWithBlockVolume(t *testing.T) {
319319
`,
320320
Check: resource.ComposeTestCheckFunc(
321321
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.block01"),
322-
isServerPresent(tt, "scaleway_instance_server.server"),
323-
isSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
322+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
323+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
324324
),
325325
},
326326

@@ -360,9 +360,9 @@ func TestAccImage_ServerWithBlockVolume(t *testing.T) {
360360
`,
361361
Check: resource.ComposeTestCheckFunc(
362362
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.block01"),
363-
isServerPresent(tt, "scaleway_instance_server.server"),
364-
isSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
365-
isSnapshotPresent(tt, "scaleway_instance_snapshot.server"),
363+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
364+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
365+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.server"),
366366
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
367367
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.server", "id"),
368368
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.block01", "id"),
@@ -419,10 +419,10 @@ func TestAccImage_ServerWithBlockVolume(t *testing.T) {
419419
Check: resource.ComposeTestCheckFunc(
420420
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.block01"),
421421
instancechecks.IsVolumePresent(tt, "scaleway_instance_volume.block02"),
422-
isServerPresent(tt, "scaleway_instance_server.server"),
423-
isSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
424-
isSnapshotPresent(tt, "scaleway_instance_snapshot.block02"),
425-
isSnapshotPresent(tt, "scaleway_instance_snapshot.server"),
422+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
423+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.block01"),
424+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.block02"),
425+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.server"),
426426
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
427427
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.server", "id"),
428428
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.block02", "id"),
@@ -445,7 +445,7 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
445445
ProtoV6ProviderFactories: tt.ProviderFactories,
446446
CheckDestroy: resource.ComposeTestCheckFunc(
447447
isImageDestroyed(tt),
448-
isSnapshotDestroyed(tt),
448+
instancechecks.IsSnapshotDestroyed(tt),
449449
instancechecks.IsVolumeDestroyed(tt),
450450
instancechecks.IsServerDestroyed(tt),
451451
),
@@ -488,12 +488,12 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
488488
}
489489
`,
490490
Check: resource.ComposeTestCheckFunc(
491-
isServerPresent(tt, "scaleway_instance_server.server01"),
492-
isServerPresent(tt, "scaleway_instance_server.server02"),
493-
isServerPresent(tt, "scaleway_instance_server.server03"),
494-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
495-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
496-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
491+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server01"),
492+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server02"),
493+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server03"),
494+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
495+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
496+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
497497
),
498498
},
499499
{
@@ -545,9 +545,9 @@ func TestAccImage_ServerWithLocalVolume(t *testing.T) {
545545
}
546546
`,
547547
Check: resource.ComposeTestCheckFunc(
548-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
549-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
550-
isSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
548+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local01"),
549+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local02"),
550+
instancechecks.IsSnapshotPresent(tt, "scaleway_instance_snapshot.local03"),
551551
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
552552
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.local01", "id"),
553553
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume.0.id", "scaleway_instance_snapshot.local01", "id"),
@@ -598,7 +598,7 @@ func TestAccImage_ServerWithSBSVolume(t *testing.T) {
598598
`,
599599
Check: resource.ComposeTestCheckFunc(
600600
blocktestfuncs.IsVolumePresent(tt, "scaleway_block_volume.block01"),
601-
isServerPresent(tt, "scaleway_instance_server.server"),
601+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
602602
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.block01"),
603603
),
604604
},
@@ -636,7 +636,7 @@ func TestAccImage_ServerWithSBSVolume(t *testing.T) {
636636
`,
637637
Check: resource.ComposeTestCheckFunc(
638638
blocktestfuncs.IsVolumePresent(tt, "scaleway_block_volume.block01"),
639-
isServerPresent(tt, "scaleway_instance_server.server"),
639+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
640640
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.block01"),
641641
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.server"),
642642
instancechecks.DoesImageExists(tt, "scaleway_instance_image.main"),
@@ -691,7 +691,7 @@ func TestAccImage_ServerWithSBSVolume(t *testing.T) {
691691
Check: resource.ComposeTestCheckFunc(
692692
blocktestfuncs.IsVolumePresent(tt, "scaleway_block_volume.block01"),
693693
blocktestfuncs.IsVolumePresent(tt, "scaleway_block_volume.block02"),
694-
isServerPresent(tt, "scaleway_instance_server.server"),
694+
instancechecks.IsServerPresent(tt, "scaleway_instance_server.server"),
695695
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.block01"),
696696
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.block02"),
697697
blocktestfuncs.IsSnapshotPresent(tt, "scaleway_block_snapshot.server"),

internal/services/instance/server_data_source_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func TestAccDataSourceServer_Basic(t *testing.T) {
4646
server_id = "${scaleway_instance_server.main.id}"
4747
}`, serverName),
4848
Check: resource.ComposeTestCheckFunc(
49-
isServerPresent(tt, "data.scaleway_instance_server.prod"),
49+
instancechecks.IsServerPresent(tt, "data.scaleway_instance_server.prod"),
5050
resource.TestCheckResourceAttr("data.scaleway_instance_server.prod", "name", serverName),
51-
isServerPresent(tt, "data.scaleway_instance_server.stg"),
51+
instancechecks.IsServerPresent(tt, "data.scaleway_instance_server.stg"),
5252
resource.TestCheckResourceAttr("data.scaleway_instance_server.stg", "name", serverName),
5353
),
5454
},

0 commit comments

Comments
 (0)