feat: add project_id and region attributes to database data source schema and refactor user model mapping
This commit is contained in:
parent
1284bcc8a3
commit
f0e7c19cdf
8 changed files with 51 additions and 630 deletions
|
|
@ -27,17 +27,14 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
testRegion,
|
||||
DataSourceModel{
|
||||
UserModel: data.UserModel{
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(0),
|
||||
Status: types.StringValue(""),
|
||||
Region: types.StringValue(testRegion),
|
||||
ConnectionString: types.StringValue(""),
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Status: types.StringValue(""),
|
||||
Region: types.StringValue(testRegion),
|
||||
},
|
||||
TerraformID: types.StringValue("pid,region,iid,1"),
|
||||
},
|
||||
|
|
@ -52,8 +49,6 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
"",
|
||||
},
|
||||
Name: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{
|
||||
|
|
@ -73,11 +68,8 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
),
|
||||
),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringValue(""),
|
||||
ConnectionString: types.StringValue(""),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringValue(""),
|
||||
},
|
||||
TerraformID: types.StringValue("pid,region,iid,1"),
|
||||
},
|
||||
|
|
@ -86,28 +78,22 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&postgresflex.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]postgresflex.UserRole{},
|
||||
Name: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
Status: utils.Ptr("status"),
|
||||
ConnectionString: utils.Ptr("connection_string"),
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]postgresflex.UserRole{},
|
||||
Name: nil,
|
||||
Status: utils.Ptr("status"),
|
||||
},
|
||||
testRegion,
|
||||
DataSourceModel{
|
||||
UserModel: data.UserModel{
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Host: types.StringValue(""),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringValue("status"),
|
||||
ConnectionString: types.StringValue("connection_string"),
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringValue(""),
|
||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringValue("status"),
|
||||
},
|
||||
TerraformID: types.StringValue("pid,region,iid,1"),
|
||||
},
|
||||
|
|
@ -186,8 +172,6 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Name: types.StringNull(),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Password: types.StringNull(),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
ConnectionString: types.StringNull(),
|
||||
|
|
@ -199,10 +183,9 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&postgresflex.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Name: utils.Ptr("username"),
|
||||
ConnectionString: utils.Ptr("connection_string"),
|
||||
Status: utils.Ptr("status"),
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Name: utils.Ptr("username"),
|
||||
Status: utils.Ptr("status"),
|
||||
},
|
||||
testRegion,
|
||||
ResourceModel{
|
||||
|
|
@ -213,8 +196,6 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Name: types.StringValue("username"),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Password: types.StringNull(),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringValue("status"),
|
||||
ConnectionString: types.StringValue("connection_string"),
|
||||
|
|
@ -226,10 +207,9 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&postgresflex.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Name: nil,
|
||||
ConnectionString: nil,
|
||||
Status: nil,
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Name: nil,
|
||||
Status: nil,
|
||||
},
|
||||
testRegion,
|
||||
ResourceModel{
|
||||
|
|
@ -240,8 +220,6 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Name: types.StringNull(),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Password: types.StringNull(),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
ConnectionString: types.StringNull(),
|
||||
|
|
@ -323,8 +301,6 @@ func TestMapFields(t *testing.T) {
|
|||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Null(),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
ConnectionString: types.StringNull(),
|
||||
|
|
@ -343,8 +319,6 @@ func TestMapFields(t *testing.T) {
|
|||
"",
|
||||
},
|
||||
Name: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
testRegion,
|
||||
ResourceModel{
|
||||
|
|
@ -363,8 +337,6 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
),
|
||||
),
|
||||
Host: types.StringValue("host"),
|
||||
Port: types.Int64Value(1234),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
ConnectionString: types.StringNull(),
|
||||
|
|
@ -378,8 +350,6 @@ func TestMapFields(t *testing.T) {
|
|||
&postgresflex.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Name: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
},
|
||||
testRegion,
|
||||
ResourceModel{
|
||||
|
|
@ -390,8 +360,6 @@ func TestMapFields(t *testing.T) {
|
|||
ProjectId: types.StringValue("pid"),
|
||||
Name: types.StringNull(),
|
||||
Roles: types.List(types.SetNull(types.StringType)),
|
||||
Host: types.StringNull(),
|
||||
Port: types.Int64Value(2123456789),
|
||||
Region: types.StringValue(testRegion),
|
||||
Status: types.StringNull(),
|
||||
ConnectionString: types.StringNull(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue