Skip to content

Commit

Permalink
Fix some tests and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Nov 8, 2024
1 parent 2798c88 commit 8cef2db
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 179 deletions.
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func DataSourceOutscaleVMRead(d *schema.ResourceData, meta interface{}) error {
instanceID, instanceIDOk := d.GetOk("vm_id")
var err error
if !filtersOk && !instanceIDOk {
return fmt.Errorf("One of filters, or instance_id must be assigned")
return fmt.Errorf("one of filters, or instance_id must be assigned")
}
// Build up search parameters
params := oscgo.ReadVmsRequest{}
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_vm_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestAccVM_TypesDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleVMTypesConfig(omi, "tinav4.c1r1p1"),
Config: testAccDataSourceOutscaleVMTypesConfig(omi, "tinav5.c2r2p2"),
},
},
})
Expand Down
22 changes: 14 additions & 8 deletions outscale/resource_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ func testAccCheckOutscaleAccessKeyExists(resourceName string) resource.TestCheck
return fmt.Errorf("No Access ID is set")
}
conn := testAccProvider.Meta().(*OutscaleClient).OSCAPI

filter := oscgo.ReadSecretAccessKeyRequest{
AccessKeyId: rs.Primary.ID,
filter := oscgo.FiltersAccessKeys{
AccessKeyIds: &[]string{rs.Primary.ID},
}
req := oscgo.ReadAccessKeysRequest{
Filters: &filter,
}

err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, httpResp, err := conn.AccessKeyApi.ReadSecretAccessKey(context.Background()).ReadSecretAccessKeyRequest(filter).Execute()
_, httpResp, err := conn.AccessKeyApi.ReadAccessKeys(context.Background()).ReadAccessKeysRequest(req).Execute()
if err != nil {
return utils.CheckThrottling(httpResp, err)
}
Expand All @@ -195,12 +198,15 @@ func testAccCheckOutscaleAccessKeyDestroy(s *terraform.State) error {
if rs.Type != "outscale_access_key" {
continue
}

filter := oscgo.ReadSecretAccessKeyRequest{
AccessKeyId: rs.Primary.ID,
filter := oscgo.FiltersAccessKeys{
AccessKeyIds: &[]string{rs.Primary.ID},
}
req := oscgo.ReadAccessKeysRequest{
Filters: &filter,
}

err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, httpResp, err := conn.AccessKeyApi.ReadSecretAccessKey(context.Background()).ReadSecretAccessKeyRequest(filter).Execute()
_, httpResp, err := conn.AccessKeyApi.ReadAccessKeys(context.Background()).ReadAccessKeysRequest(req).Execute()
if err != nil {
return utils.CheckThrottling(httpResp, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": null,
"backend_vm_ids": [
"##id-3##"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": null,
"backend_vm_ids": [
"##id-6##"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": [],
"backend_vm_ids": [
"##id-1##"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
"listener_rules": [
{
"action": "forward",
"host_name_pattern": "",
"host_name_pattern": "*.abc.-.abc.*.com",
"listener_id": "##id-1##",
"listener_rule_id": "##id-2##",
"listener_rule_name": "########",
"path_pattern": "*.abc.*.abc.*.com",
"priority": 10,
"path_pattern": "",
"priority": 1,
"vm_ids": [
"##id-3##"
]
},
{
"action": "forward",
"host_name_pattern": "*.abc.-.abc.*.com",
"host_name_pattern": "",
"listener_id": "##id-1##",
"listener_rule_id": "##id-4##",
"listener_rule_name": "########",
"path_pattern": "",
"priority": 1,
"path_pattern": "*.abc.*.abc.*.com",
"priority": 10,
"vm_ids": [
"##id-3##"
]
Expand Down Expand Up @@ -163,7 +163,7 @@
"action": "forward",
"host_name_pattern": "",
"listener_id": "##id-1##",
"listener_rule_id": "##id-2##",
"listener_rule_id": "##id-4##",
"listener_rule_name": "########",
"path_pattern": "*.abc.*.abc.*.com",
"priority": 10
Expand Down Expand Up @@ -206,7 +206,7 @@
"action": "forward",
"host_name_pattern": "*.abc.-.abc.*.com",
"listener_id": "##id-1##",
"listener_rule_id": "##id-4##",
"listener_rule_id": "##id-2##",
"listener_rule_name": "########",
"path_pattern": "",
"priority": 1
Expand Down Expand Up @@ -237,6 +237,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": null,
"backend_vm_ids": [
"##id-3##"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": null,
"backend_vm_ids": [
"##id-0##"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": null,
"backend_vm_ids": [
"##id-3##",
"##id-4##"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@
{
"schema_version": 0,
"attributes": {
"backend_ips": [],
"backend_vm_ids": [
"##id-2##"
"##id-1##"
],
"id": "##id-5##",
"load_balancer_name": "########",
Expand Down Expand Up @@ -197,7 +198,7 @@
"deletion_protection": false,
"get_admin_password": null,
"hypervisor": "xen",
"id": "##id-2##",
"id": "##id-1##",
"image_id": "##id-9##",
"is_source_dest_checked": false,
"keypair_name": "KP-TF93",
Expand Down Expand Up @@ -243,7 +244,7 @@
],
"timeouts": null,
"user_data": "ICAgICAjIS9iaW4vYmFzaAogICAgcHVzaGQgL2hvbWUKICAgIG5vaHVwIHB5dGhvbiAtbSBTaW1wbGVIVFRQU2VydmVyIDgwODAK",
"vm_id": "##id-2##",
"vm_id": "##id-1##",
"vm_initiated_shutdown_behavior": "stop",
"vm_type": "###vm_type###"
},
Expand Down Expand Up @@ -281,7 +282,7 @@
"deletion_protection": false,
"get_admin_password": null,
"hypervisor": "xen",
"id": "##id-1##",
"id": "##id-2##",
"image_id": "##id-9##",
"is_source_dest_checked": false,
"keypair_name": "KP-TF93",
Expand Down Expand Up @@ -327,7 +328,7 @@
],
"timeouts": null,
"user_data": "ICAgICAjIS9iaW4vYmFzaAogICAgcHVzaGQgL2hvbWUKICAgIG5vaHVwIHB5dGhvbiAtbSBTaW1wbGVIVFRQU2VydmVyIDgwODAK",
"vm_id": "##id-1##",
"vm_id": "##id-2##",
"vm_initiated_shutdown_behavior": "stop",
"vm_type": "###vm_type###"
},
Expand Down
Loading

0 comments on commit 8cef2db

Please sign in to comment.