Skip to content

Commit

Permalink
Fix others acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed May 15, 2024
1 parent a0a4a6e commit 0b86e5a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
16 changes: 8 additions & 8 deletions outscale/data_source_outscale_access_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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) },
Expand All @@ -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]
}
}
`
Expand Down
6 changes: 2 additions & 4 deletions outscale/data_source_outscale_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions outscale/data_source_outscale_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"),
),
},
Expand All @@ -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"),
),
},
},
Expand Down Expand Up @@ -66,38 +67,39 @@ 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"
values = ["10"]
}
filter {
name = "from_creation_date"
values = ["2023"]
values = ["%s"]
}
}
`, region)
`, region, creationDate)
}
12 changes: 6 additions & 6 deletions outscale/resource_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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"
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -214,19 +214,19 @@ 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)
}

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)
Expand Down
2 changes: 1 addition & 1 deletion outscale/resource_outscale_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b86e5a

Please sign in to comment.