From 41d4bc16224179ad7caf5eeedb3be8348ce6dc76 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 7 Apr 2017 10:42:27 +0100 Subject: [PATCH] Adding tests covering low latency storage --- .../opc/import_storage_volume_test.go | 22 +++++++++++++ .../opc/resource_storage_volume_test.go | 33 +++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/builtin/providers/opc/import_storage_volume_test.go b/builtin/providers/opc/import_storage_volume_test.go index f6af66226f..fdd8714627 100644 --- a/builtin/providers/opc/import_storage_volume_test.go +++ b/builtin/providers/opc/import_storage_volume_test.go @@ -118,6 +118,28 @@ func TestAccOPCStorageVolume_importImageListEntry(t *testing.T) { }) } +func TestAccOPCStorageVolume_importLowLatency(t *testing.T) { + resourceName := "opc_compute_storage_volume.test" + rInt := acctest.RandInt() + config := testAccStorageVolumeLowLatency(rInt) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: opcResourceCheck(resourceName, testAccCheckStorageVolumeDestroyed), + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccOPCStorageVolume_importFromSnapshot(t *testing.T) { resourceName := "opc_compute_storage_volume.test" rInt := acctest.RandInt() diff --git a/builtin/providers/opc/resource_storage_volume_test.go b/builtin/providers/opc/resource_storage_volume_test.go index a9baefceda..cf22098027 100644 --- a/builtin/providers/opc/resource_storage_volume_test.go +++ b/builtin/providers/opc/resource_storage_volume_test.go @@ -136,6 +136,27 @@ func TestAccOPCStorageVolume_ImageListEntry(t *testing.T) { }) } +func TestAccOPCStorageVolume_LowLatency(t *testing.T) { + volumeResourceName := "opc_compute_storage_volume.test" + rInt := acctest.RandInt() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + CheckDestroy: opcResourceCheck(volumeResourceName, testAccCheckStorageVolumeDestroyed), + Steps: []resource.TestStep{ + { + Config: testAccStorageVolumeLowLatency(rInt), + Check: resource.ComposeTestCheckFunc( + opcResourceCheck(volumeResourceName, testAccCheckStorageVolumeExists), + resource.TestCheckResourceAttr(volumeResourceName, "storage_type", "/oracle/public/storage/latency"), + ), + }, + }, + }) +} + func TestAccOPCStorageVolume_FromSnapshot(t *testing.T) { volumeResourceName := "opc_compute_storage_volume.test" rInt := acctest.RandInt() @@ -160,8 +181,6 @@ func TestAccOPCStorageVolume_FromSnapshot(t *testing.T) { }) } -// TODO: test Premium storage - func testAccCheckStorageVolumeExists(state *OPCResourceState) error { sv := state.Client.StorageVolumes() volumeName := state.Attributes["name"] @@ -302,3 +321,13 @@ func testAccStorageVolumeFromSnapshot(rInt int) string { snapshot_id = "${opc_compute_storage_volume_snapshot.foo.snapshot_id}" }`, rInt, rInt, rInt) } + +func testAccStorageVolumeLowLatency(rInt int) string { + return fmt.Sprintf(` + resource "opc_compute_storage_volume" "test" { + name = "test-acc-stor-vol-ll-%d" + description = "Acc Test Storage Volume Low Latency" + storage_type = "/oracle/public/storage/latency" + size = 5 + }`, rInt) +}