From 0b86e5ac72e441b97f2ab6b538554f5ba497a874 Mon Sep 17 00:00:00 2001 From: Thiery Ouattara Date: Wed, 15 May 2024 08:28:13 +0000 Subject: [PATCH] Fix others acceptance tests --- .../data_source_outscale_access_keys_test.go | 16 ++++++------- outscale/data_source_outscale_snapshot.go | 6 ++--- .../data_source_outscale_snapshot_test.go | 24 ++++++++++--------- outscale/resource_outscale_access_key_test.go | 12 +++++----- outscale/resource_outscale_snapshot.go | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/outscale/data_source_outscale_access_keys_test.go b/outscale/data_source_outscale_access_keys_test.go index 2f37fa72d..1aba0db5f 100644 --- a/outscale/data_source_outscale_access_keys_test.go +++ b/outscale/data_source_outscale_access_keys_test.go @@ -8,7 +8,7 @@ import ( func TestAccOthers_DataSourceAccessKeys_basic(t *testing.T) { t.Parallel() - dataSourceName := "data.outscale_access_keys.outscale_access_key" + dataSourceName := "data.outscale_access_keys.read_access_key" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -27,7 +27,7 @@ func TestAccOthers_DataSourceAccessKeys_basic(t *testing.T) { func TestAccOthers_DataSourceAccessKeys_withFilters(t *testing.T) { t.Parallel() - dataSourceName := "data.outscale_access_keys.outscale_access_key" + dataSourceName := "data.outscale_access_keys.filters_access_key" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -46,22 +46,22 @@ func TestAccOthers_DataSourceAccessKeys_withFilters(t *testing.T) { func testAccClientAccessKeysDataSourceBasic() string { return ` - resource "outscale_access_key" "outscale_access_key" {} + resource "outscale_access_key" "data_access_key" {} - data "outscale_access_keys" "outscale_access_key" { - access_key_ids = [outscale_access_key.outscale_access_key.id] + data "outscale_access_keys" "read_access_key" { + access_key_ids = [outscale_access_key.data_access_key.id] } ` } func testAccClientAccessKeysDataSourceWithFilters() string { return ` - resource "outscale_access_key" "outscale_access_key" {} + resource "outscale_access_key" "datas_access_key" {} - data "outscale_access_keys" "outscale_access_key" { + data "outscale_access_keys" "filters_access_key" { filter { name = "access_key_ids" - values = [outscale_access_key.outscale_access_key.id] + values = [outscale_access_key.datas_access_key.id] } } ` diff --git a/outscale/data_source_outscale_snapshot.go b/outscale/data_source_outscale_snapshot.go index 481bb8d93..06739509a 100644 --- a/outscale/data_source_outscale_snapshot.go +++ b/outscale/data_source_outscale_snapshot.go @@ -114,12 +114,10 @@ func DataSourceOutscaleSnapshotRead(d *schema.ResourceData, meta interface{}) er } } if ownersOk { - filter.SetAccountIds([]string{owners.(string)}) - params.SetFilters(filter) + params.Filters.SetAccountIds([]string{owners.(string)}) } if snapshotIdsOk { - filter.SetSnapshotIds([]string{snapshotIds.(string)}) - params.SetFilters(filter) + params.Filters.SetSnapshotIds([]string{snapshotIds.(string)}) } var resp oscgo.ReadSnapshotsResponse diff --git a/outscale/data_source_outscale_snapshot_test.go b/outscale/data_source_outscale_snapshot_test.go index d00144cc0..39f89f5de 100644 --- a/outscale/data_source_outscale_snapshot_test.go +++ b/outscale/data_source_outscale_snapshot_test.go @@ -3,6 +3,7 @@ package outscale import ( "fmt" "testing" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -19,7 +20,7 @@ func TestAccOthers_SnapshotDataSource_basic(t *testing.T) { { Config: testAccCheckOutscaleSnapshotDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleSnapshotDataSourceID("data.outscale_snapshot.snapshot"), + testAccCheckOutscaleSnapshotDataSourceID("data.outscale_snapshot.snapshot_test"), resource.TestCheckResourceAttr("data.outscale_snapshot.snapshot", "volume_size", "1"), ), }, @@ -37,8 +38,8 @@ func TestAccOthers_SnapshotDataSource_multipleFilters(t *testing.T) { { Config: testAccCheckOutscaleSnapshotDataSourceConfigWithMultipleFilters(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleSnapshotDataSourceID("data.outscale_snapshot.snapshot"), - resource.TestCheckResourceAttr("data.outscale_snapshot.snapshot", "volume_size", "10"), + testAccCheckOutscaleSnapshotDataSourceID("data.outscale_snapshot.snapshot_filters"), + resource.TestCheckResourceAttr("data.outscale_snapshot.snapshot_filters", "volume_size", "10"), ), }, }, @@ -66,29 +67,30 @@ func testAccCheckOutscaleSnapshotDataSourceConfig(region string) string { size = 1 } - resource "outscale_snapshot" "snapshot" { + resource "outscale_snapshot" "snapshot_01" { volume_id = outscale_volume.example.id } - data "outscale_snapshot" "snapshot" { - snapshot_id = outscale_snapshot.snapshot.id + data "outscale_snapshot" "snapshot_test" { + snapshot_id = outscale_snapshot.snapshot_01.id } `, region) } func testAccCheckOutscaleSnapshotDataSourceConfigWithMultipleFilters(region string) string { + creationDate := time.Now().Format("2006-01-02") return fmt.Sprintf(` resource "outscale_volume" "external1" { subregion_name = "%sa" size = 10 } - resource "outscale_snapshot" "snapshot" { + resource "outscale_snapshot" "snapshot_t2" { volume_id = outscale_volume.external1.id } - data "outscale_snapshot" "snapshot" { - snapshot_id = outscale_snapshot.snapshot.id + data "outscale_snapshot" "snapshot_filters" { + snapshot_id = outscale_snapshot.snapshot_t2.id filter { name = "volume_sizes" @@ -96,8 +98,8 @@ func testAccCheckOutscaleSnapshotDataSourceConfigWithMultipleFilters(region stri } filter { name = "from_creation_date" - values = ["2023"] + values = ["%s"] } } - `, region) + `, region, creationDate) } diff --git a/outscale/resource_outscale_access_key_test.go b/outscale/resource_outscale_access_key_test.go index d4a404202..690439ad6 100644 --- a/outscale/resource_outscale_access_key_test.go +++ b/outscale/resource_outscale_access_key_test.go @@ -14,7 +14,7 @@ import ( func TestAccOthers_AccessKey_basic(t *testing.T) { t.Parallel() - resourceName := "outscale_access_key.outscale_access_key" + resourceName := "outscale_access_key.basic_access_key" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -40,7 +40,7 @@ func TestAccOthers_AccessKey_basic(t *testing.T) { func TestAccOthers_AccessKey_updatedToInactivedKey(t *testing.T) { t.Parallel() - resourceName := "outscale_access_key.outscale_access_key" + resourceName := "outscale_access_key.update_access_key" state := "ACTIVE" stateUpdated := "INACTIVE" @@ -122,7 +122,7 @@ func TestAccOthers_AccessKey_updatedToActivedKey(t *testing.T) { } func TestAccOthers_AccessKey_updatedExpirationDate(t *testing.T) { - resourceName := "outscale_access_key.outscale_access_key" + resourceName := "outscale_access_key.date_access_key" expirDate := time.Now().AddDate(1, 1, 0).Format("2006-01-02") expirDateUpdated := time.Now().AddDate(1, 4, 0).Format("2006-01-02") @@ -214,11 +214,11 @@ func testAccCheckOutscaleAccessKeyDestroy(s *terraform.State) error { } const testAccOutscaleAccessKeyBasicConfig = ` - resource "outscale_access_key" "outscale_access_key" {}` + resource "outscale_access_key" "basic_access_key" {}` func testAccOutscaleAccessKeyUpdatedConfig(state string) string { return fmt.Sprintf(` - resource "outscale_access_key" "outscale_access_key" { + resource "outscale_access_key" "update_access_key" { state = "%s" } `, state) @@ -226,7 +226,7 @@ func testAccOutscaleAccessKeyUpdatedConfig(state string) string { func testAccOutscaleAccessKeyExpirationDateConfig(expirDate string) string { return fmt.Sprintf(` - resource "outscale_access_key" "outscale_access_key" { + resource "outscale_access_key" "date_access_key" { expiration_date = "%s" } `, expirDate) diff --git a/outscale/resource_outscale_snapshot.go b/outscale/resource_outscale_snapshot.go index bb9048c4a..69afed262 100644 --- a/outscale/resource_outscale_snapshot.go +++ b/outscale/resource_outscale_snapshot.go @@ -169,7 +169,7 @@ func ResourceOutscaleSnapshotCreate(d *schema.ResourceData, meta interface{}) er log.Printf("Waiting for Snapshot %s to become available...", resp.Snapshot.GetSnapshotId()) stateConf := &resource.StateChangeConf{ - Pending: []string{"pending", "pending/queued", "queued", "importing"}, + Pending: []string{"pending", "in-queue", "queued", "importing"}, Target: []string{"completed"}, Refresh: SnapshotOAPIStateRefreshFunc(conn, resp.Snapshot.GetSnapshotId()), Timeout: OutscaleImageRetryTimeout,