feat(postgresql): Region adjustment (#713)
Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
This commit is contained in:
parent
e989102d6b
commit
6cc1dffc22
19 changed files with 458 additions and 148 deletions
|
|
@ -11,9 +11,11 @@ import (
|
|||
)
|
||||
|
||||
func TestMapDataSourceFields(t *testing.T) {
|
||||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *postgresflex.GetUserResponse
|
||||
region string
|
||||
expected DataSourceModel
|
||||
isValid bool
|
||||
}{
|
||||
|
|
@ -22,8 +24,9 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -31,6 +34,7 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
Roles: types.SetNull(types.StringType),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -48,8 +52,9 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -59,8 +64,9 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
types.StringValue("role_2"),
|
||||
types.StringValue(""),
|
||||
}),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -75,8 +81,9 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(2123456789)),
|
||||
},
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
Id: types.StringValue("pid,region,iid,uid"),
|
||||
UserId: types.StringValue("uid"),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -84,18 +91,21 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
Roles: types.SetValueMust(types.StringType, []attr.Value{}),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"nil_response",
|
||||
nil,
|
||||
testRegion,
|
||||
DataSourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&postgresflex.GetUserResponse{},
|
||||
testRegion,
|
||||
DataSourceModel{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -104,6 +114,7 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -115,7 +126,7 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
InstanceId: tt.expected.InstanceId,
|
||||
UserId: tt.expected.UserId,
|
||||
}
|
||||
err := mapDataSourceFields(tt.input, state)
|
||||
err := mapDataSourceFields(tt.input, state, tt.region)
|
||||
if !tt.isValid && err == nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue