Skip to content

Commit

Permalink
Convert to new-style fixture applies and list resources in alphabetic…
Browse files Browse the repository at this point in the history
…al order
  • Loading branch information
neinkeinkaffee committed May 30, 2022
1 parent 05ef3ed commit ef954da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions aws/resource_service_principal_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"github.com/databrickslabs/terraform-provider-databricks/scim"

"github.com/databrickslabs/terraform-provider-databricks/qa"
"github.com/stretchr/testify/assert"
)

func TestResourceServicePrincipalRoleCreate(t *testing.T) {
d, err := qa.ResourceFixture{
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "PATCH",
Expand Down Expand Up @@ -45,13 +44,11 @@ func TestResourceServicePrincipalRoleCreate(t *testing.T) {
"role": "arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile",
},
Create: true,
}.Apply(t)
assert.NoError(t, err, err)
assert.Equal(t, "abc|arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile", d.Id())
}.ApplyAndExpectData(t, map[string]interface{}{"id": "abc|arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile"})
}

func TestResourceServicePrincipalRoleCreate_Error(t *testing.T) {
d, err := qa.ResourceFixture{
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "PATCH",
Expand All @@ -69,13 +66,11 @@ func TestResourceServicePrincipalRoleCreate_Error(t *testing.T) {
"role": "arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile",
},
Create: true,
}.Apply(t)
qa.AssertErrorStartsWith(t, err, "Internal error happened")
assert.Equal(t, "", d.Id(), "Id should be empty for error creates")
}.ExpectError(t, "Internal error happened")
}

func TestResourceServicePrincipalRoleRead(t *testing.T) {
d, err := qa.ResourceFixture{
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "GET",
Expand All @@ -95,9 +90,7 @@ func TestResourceServicePrincipalRoleRead(t *testing.T) {
Resource: ResourceServicePrincipalRole(),
Read: true,
ID: "abc|arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile",
}.Apply(t)
assert.NoError(t, err, err)
assert.Equal(t, "abc|arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile", d.Id(), "Id should not be empty")
}.ApplyAndExpectData(t, map[string]interface{}{"id": "abc|arn:aws:iam::999999999999:instance-profile/my-fake-instance-profile"})
}

func TestResourceServicePrincipalRoleRead_NoRole(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func DatabricksProvider() *schema.Provider {
"databricks_secret_scope": secrets.ResourceSecretScope(),
"databricks_secret_acl": secrets.ResourceSecretACL(),
"databricks_service_principal": scim.ResourceServicePrincipal(),
"databricks_service_principal_role": aws.ResourceServicePrincipalRole(),
"databricks_sql_dashboard": sql.ResourceDashboard(),
"databricks_sql_endpoint": sql.ResourceSQLEndpoint(),
"databricks_sql_global_config": sql.ResourceSQLGlobalConfig(),
Expand All @@ -116,7 +117,6 @@ func DatabricksProvider() *schema.Provider {
"databricks_user": scim.ResourceUser(),
"databricks_user_instance_profile": aws.ResourceUserInstanceProfile(),
"databricks_user_role": aws.ResourceUserRole(),
"databricks_service_principal_role": aws.ResourceServicePrincipalRole(),
"databricks_workspace_conf": workspace.ResourceWorkspaceConf(),
},
Schema: providerSchema(),
Expand Down

0 comments on commit ef954da

Please sign in to comment.