feat: enhance database resource model with additional attributes and refactor data source schema
This commit is contained in:
parent
c4891b770d
commit
1284bcc8a3
6 changed files with 66 additions and 80 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
|
||||
datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen"
|
||||
resource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/resources_gen"
|
||||
)
|
||||
|
||||
func TestMapFields(t *testing.T) {
|
||||
|
|
@ -41,12 +40,15 @@ func TestMapFields(t *testing.T) {
|
|||
expected: expected{
|
||||
model: &DataSourceModel{
|
||||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
Region: types.StringValue("eu01"),
|
||||
DatabaseId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("my-instance"),
|
||||
ProjectId: types.StringValue("my-project"),
|
||||
},
|
||||
Region: types.StringValue("eu01"),
|
||||
DatabaseID: types.Int64Value(1),
|
||||
TerraformID: types.StringValue("my-project,eu01,my-instance,1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -59,7 +61,9 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
model: &DataSourceModel{
|
||||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Id: types.Int64Value(1),
|
||||
ProjectId: types.StringValue("my-project"),
|
||||
InstanceId: types.StringValue("my-instance"),
|
||||
},
|
||||
},
|
||||
region: "eu01",
|
||||
|
|
@ -69,10 +73,12 @@ func TestMapFields(t *testing.T) {
|
|||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringNull(),
|
||||
Owner: types.StringNull(), DatabaseId: types.Int64Value(1),
|
||||
Region: types.StringValue("eu01"),
|
||||
InstanceId: types.StringValue("my-instance"),
|
||||
ProjectId: types.StringValue("my-project"),
|
||||
},
|
||||
DatabaseID: types.Int64Value(1),
|
||||
Region: types.StringValue("eu01"),
|
||||
TerraformID: types.StringValue("my-project,eu01,my-instance,1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -146,12 +152,10 @@ func TestMapResourceFields(t *testing.T) {
|
|||
},
|
||||
expected: expected{
|
||||
model: &ResourceModel{
|
||||
DatabaseModel: resource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
},
|
||||
DatabaseID: types.Int64Value(1),
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
DatabaseId: types.Int64Value(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -200,10 +204,8 @@ func TestToCreatePayload(t *testing.T) {
|
|||
name: "should convert model to payload",
|
||||
given: given{
|
||||
model: &ResourceModel{
|
||||
DatabaseModel: resource.DatabaseModel{
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
},
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
},
|
||||
},
|
||||
expected: expected{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue