feat: refactor data source models and update mapping functions for improved consistency
This commit is contained in:
parent
f0e7c19cdf
commit
184e133a2a
34 changed files with 980 additions and 1017 deletions
|
|
@ -13,11 +13,11 @@ import (
|
|||
func TestMapFields(t *testing.T) {
|
||||
type given struct {
|
||||
source *postgresflexalpha.ListDatabase
|
||||
model *DataSourceModel
|
||||
model *dataSourceModel
|
||||
region string
|
||||
}
|
||||
type expected struct {
|
||||
model *DataSourceModel
|
||||
model *dataSourceModel
|
||||
err bool
|
||||
}
|
||||
|
||||
|
|
@ -34,11 +34,11 @@ func TestMapFields(t *testing.T) {
|
|||
Name: utils.Ptr("my-db"),
|
||||
Owner: utils.Ptr("\"my-owner\""),
|
||||
},
|
||||
model: &DataSourceModel{},
|
||||
model: &dataSourceModel{},
|
||||
region: "eu01",
|
||||
},
|
||||
expected: expected{
|
||||
model: &DataSourceModel{
|
||||
model: &dataSourceModel{
|
||||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
|
|
@ -59,7 +59,7 @@ func TestMapFields(t *testing.T) {
|
|||
Id: utils.Ptr(int64(1)),
|
||||
Name: utils.Ptr("my-db"),
|
||||
},
|
||||
model: &DataSourceModel{
|
||||
model: &dataSourceModel{
|
||||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
ProjectId: types.StringValue("my-project"),
|
||||
|
|
@ -69,7 +69,7 @@ func TestMapFields(t *testing.T) {
|
|||
region: "eu01",
|
||||
},
|
||||
expected: expected{
|
||||
model: &DataSourceModel{
|
||||
model: &dataSourceModel{
|
||||
DatabaseModel: datasource.DatabaseModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
|
|
@ -86,7 +86,7 @@ func TestMapFields(t *testing.T) {
|
|||
name: "should fail on nil source",
|
||||
given: given{
|
||||
source: nil,
|
||||
model: &DataSourceModel{},
|
||||
model: &dataSourceModel{},
|
||||
},
|
||||
expected: expected{err: true},
|
||||
},
|
||||
|
|
@ -94,7 +94,7 @@ func TestMapFields(t *testing.T) {
|
|||
name: "should fail on nil source ID",
|
||||
given: given{
|
||||
source: &postgresflexalpha.ListDatabase{Id: nil},
|
||||
model: &DataSourceModel{},
|
||||
model: &dataSourceModel{},
|
||||
},
|
||||
expected: expected{err: true},
|
||||
},
|
||||
|
|
@ -128,10 +128,10 @@ func TestMapFields(t *testing.T) {
|
|||
func TestMapResourceFields(t *testing.T) {
|
||||
type given struct {
|
||||
source *postgresflexalpha.ListDatabase
|
||||
model *ResourceModel
|
||||
model *resourceModel
|
||||
}
|
||||
type expected struct {
|
||||
model *ResourceModel
|
||||
model *resourceModel
|
||||
err bool
|
||||
}
|
||||
|
||||
|
|
@ -148,10 +148,10 @@ func TestMapResourceFields(t *testing.T) {
|
|||
Name: utils.Ptr("my-db"),
|
||||
Owner: utils.Ptr("\"my-owner\""),
|
||||
},
|
||||
model: &ResourceModel{},
|
||||
model: &resourceModel{},
|
||||
},
|
||||
expected: expected{
|
||||
model: &ResourceModel{
|
||||
model: &resourceModel{
|
||||
Id: types.Int64Value(1),
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
|
|
@ -163,7 +163,7 @@ func TestMapResourceFields(t *testing.T) {
|
|||
name: "should fail on nil source",
|
||||
given: given{
|
||||
source: nil,
|
||||
model: &ResourceModel{},
|
||||
model: &resourceModel{},
|
||||
},
|
||||
expected: expected{err: true},
|
||||
},
|
||||
|
|
@ -188,7 +188,7 @@ func TestMapResourceFields(t *testing.T) {
|
|||
|
||||
func TestToCreatePayload(t *testing.T) {
|
||||
type given struct {
|
||||
model *ResourceModel
|
||||
model *resourceModel
|
||||
}
|
||||
type expected struct {
|
||||
payload *postgresflexalpha.CreateDatabaseRequestPayload
|
||||
|
|
@ -203,7 +203,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
{
|
||||
name: "should convert model to payload",
|
||||
given: given{
|
||||
model: &ResourceModel{
|
||||
model: &resourceModel{
|
||||
Name: types.StringValue("my-db"),
|
||||
Owner: types.StringValue("my-owner"),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue