Skip to content

Commit

Permalink
fix: Re-enable has_user_data test cases (#986)
Browse files Browse the repository at this point in the history
* Re-enable has_user_data test cases

* make fmt
  • Loading branch information
lgarber-akamai authored Aug 25, 2023
1 parent 1fc9f4f commit c3aa12c
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 25 deletions.
5 changes: 3 additions & 2 deletions linode/accountlogins/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
package accountlogins

import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/linode/linodego"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/linode/linodego"
)

func TestParseLogins(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion linode/accountsettings/framework_model_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package accountsettings

import (
"github.com/linode/linodego"
"testing"

"github.com/linode/linodego"

"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand Down
3 changes: 2 additions & 1 deletion linode/backup/framework_model_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package backup

import (
"context"
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)
Expand Down
5 changes: 3 additions & 2 deletions linode/databasebackups/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
package databasebackups

import (
"testing"
"time"

"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestParseMySQLBackup(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion linode/databaseengines/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package databaseengines

import (
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)
Expand Down
3 changes: 2 additions & 1 deletion linode/domain/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package domain

import (
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)
Expand Down
5 changes: 3 additions & 2 deletions linode/firewall/firewall_helpers_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
package firewall

import (
"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"reflect"
"testing"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)

// Assertion helpers
Expand Down
3 changes: 2 additions & 1 deletion linode/instance/expand_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
package instance

import (
"github.com/linode/linodego"
"testing"

"github.com/linode/linodego"
)

func TestExpandInstanceConfigDeviceMap(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions linode/instance/flatten_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
package instance

import (
"github.com/linode/linodego"
"reflect"
"testing"
"time"

"github.com/linode/linodego"

"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -324,7 +325,6 @@ func TestFlattenInstanceConfigs(t *testing.T) {
}

for i := 0; i < len(expectedConfigs); i++ {

if !areMapsEqual(actualConfigs[i], expectedConfigs[i]) {
t.Errorf("Config %d: Mismatch between expected and actual config", i)
}
Expand Down
13 changes: 8 additions & 5 deletions linode/instance/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2016,29 +2016,32 @@ func TestAccResourceInstance_ipv4Sharing(t *testing.T) {
}

func TestAccResourceInstance_userData(t *testing.T) {
t.Skip("Skipping this test due to: 'Error creating a Linode Instance: [400] [metadata] The Metadata service is not currently available in this datacenter.'")
t.Parallel()

resName := "linode_instance.foobar"
var instance linodego.Instance
instanceName := acctest.RandomWithPrefix("tf_test")

region, err := acceptance.GetRandomRegionWithCaps([]string{"Metadata"})
if err != nil {
t.Fatal(err)
}

resource.Test(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
ProtoV5ProviderFactories: acceptance.ProtoV5ProviderFactories,
CheckDestroy: acceptance.CheckInstanceDestroy,
Steps: []resource.TestStep{
{
Config: tmpl.UserData(t, instanceName, "eu-west"),
Config: tmpl.UserData(t, instanceName, region),
Check: resource.ComposeTestCheckFunc(
acceptance.CheckInstanceExists(resName, &instance),
resource.TestCheckResourceAttr(resName, "label", instanceName),
resource.TestCheckResourceAttr(resName, "type", "g6-nanode-1"),
resource.TestCheckResourceAttr(resName, "image", acceptance.TestImageLatest),
resource.TestCheckResourceAttr(resName, "region", "eu-west"),
resource.TestCheckResourceAttr(resName, "region", region),

// TODO:: This attribute currently does not get set by the API. Need to uncomment this line when metadata api returns a valid response
// resource.TestCheckResourceAttr(resName, "has_user_data", "true"),
resource.TestCheckResourceAttr(resName, "has_user_data", "true"),
),
},
{
Expand Down
10 changes: 5 additions & 5 deletions linode/objkey/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func TestParseConfiguredAttributes(t *testing.T) {

data := ResourceModel{}
data.parseConfiguredAttributes(&key)
//assert.Equal(t, types.Int64Value(123), data.ID)
//assert.Equal(t, types.StringValue("my-key"), data.Label)
//assert.Equal(t, types.StringValue("KVAKUTGBA4WTR2NSJQ81"), data.AccessKey)
//assert.Equal(t, types.StringValue("OiA6F5r0niLs3QA2stbyq7mY5VCV7KqOzcmitmHw"), data.SecretKey)
//assert.Equal(t, types.BoolValue(true), data.Limited)
// assert.Equal(t, types.Int64Value(123), data.ID)
// assert.Equal(t, types.StringValue("my-key"), data.Label)
// assert.Equal(t, types.StringValue("KVAKUTGBA4WTR2NSJQ81"), data.AccessKey)
// assert.Equal(t, types.StringValue("OiA6F5r0niLs3QA2stbyq7mY5VCV7KqOzcmitmHw"), data.SecretKey)
// assert.Equal(t, types.BoolValue(true), data.Limited)

//assert.NotNil(t, data.BucketAccess)
//
Expand Down
4 changes: 2 additions & 2 deletions linode/user/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package user

import (
"context"
"github.com/hashicorp/terraform-plugin-framework/types"
"strconv"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -150,5 +151,4 @@ func TestParseUserGrants(t *testing.T) {
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_volumes\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"cancel_account\":false")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"longview_subscription\":true")

}

0 comments on commit c3aa12c

Please sign in to comment.