feat: rename Model to ResourceModel for clarity in user resource handling
This commit is contained in:
parent
b6d3eb3858
commit
71dae54b8b
3 changed files with 46 additions and 42 deletions
|
|
@ -169,7 +169,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
description string
|
||||
input *postgresflex.GetUserResponse
|
||||
region string
|
||||
expected Model
|
||||
expected ResourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -178,7 +178,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Id: utils.Ptr(int64(1)),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
|
|
@ -205,7 +205,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Status: utils.Ptr("status"),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
|
|
@ -232,7 +232,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
Status: nil,
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
UserId: types.Int64Value(1),
|
||||
InstanceId: types.StringValue("iid"),
|
||||
|
|
@ -254,28 +254,28 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
"nil_response",
|
||||
nil,
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&postgresflex.GetUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&postgresflex.GetUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(
|
||||
tt.description, func(t *testing.T) {
|
||||
state := &Model{
|
||||
state := &ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
ProjectId: tt.expected.ProjectId,
|
||||
InstanceId: tt.expected.InstanceId,
|
||||
|
|
@ -306,7 +306,7 @@ func TestMapFields(t *testing.T) {
|
|||
description string
|
||||
input *postgresflex.GetUserResponse
|
||||
region string
|
||||
expected Model
|
||||
expected ResourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -315,7 +315,7 @@ func TestMapFields(t *testing.T) {
|
|||
Id: utils.Ptr(int64(1)),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(int64(1)),
|
||||
|
|
@ -347,7 +347,7 @@ func TestMapFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(1234)),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
|
|
@ -382,7 +382,7 @@ func TestMapFields(t *testing.T) {
|
|||
Port: utils.Ptr(int64(2123456789)),
|
||||
},
|
||||
testRegion,
|
||||
Model{
|
||||
ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Id: types.Int64Value(1),
|
||||
UserId: types.Int64Value(1),
|
||||
|
|
@ -404,28 +404,28 @@ func TestMapFields(t *testing.T) {
|
|||
"nil_response",
|
||||
nil,
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&postgresflex.GetUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&postgresflex.GetUserResponse{},
|
||||
testRegion,
|
||||
Model{},
|
||||
ResourceModel{},
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(
|
||||
tt.description, func(t *testing.T) {
|
||||
state := &Model{
|
||||
state := &ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
ProjectId: tt.expected.ProjectId,
|
||||
InstanceId: tt.expected.InstanceId,
|
||||
|
|
@ -452,14 +452,14 @@ func TestMapFields(t *testing.T) {
|
|||
func TestToCreatePayload(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *Model
|
||||
input *ResourceModel
|
||||
inputRoles *[]string
|
||||
expected *postgresflex.CreateUserRequestPayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
&ResourceModel{},
|
||||
&[]string{},
|
||||
&postgresflex.CreateUserRequestPayload{
|
||||
Name: nil,
|
||||
|
|
@ -469,7 +469,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&Model{
|
||||
&ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Name: types.StringValue("username"),
|
||||
},
|
||||
|
|
@ -489,7 +489,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&Model{
|
||||
&ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Name: types.StringNull(),
|
||||
},
|
||||
|
|
@ -514,7 +514,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_roles",
|
||||
&Model{},
|
||||
&ResourceModel{},
|
||||
nil,
|
||||
nil,
|
||||
false,
|
||||
|
|
@ -544,14 +544,14 @@ func TestToCreatePayload(t *testing.T) {
|
|||
func TestToUpdatePayload(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *Model
|
||||
input *ResourceModel
|
||||
inputRoles *[]string
|
||||
expected *postgresflex.UpdateUserRequestPayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
&ResourceModel{},
|
||||
&[]string{},
|
||||
&postgresflex.UpdateUserRequestPayload{
|
||||
Roles: &[]postgresflex.UserRole{},
|
||||
|
|
@ -560,7 +560,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"default_values",
|
||||
&Model{
|
||||
&ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Name: types.StringValue("username"),
|
||||
},
|
||||
|
|
@ -580,7 +580,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&Model{
|
||||
&ResourceModel{
|
||||
UserModel: resource.UserModel{
|
||||
Name: types.StringNull(),
|
||||
},
|
||||
|
|
@ -604,7 +604,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_roles",
|
||||
&Model{},
|
||||
&ResourceModel{},
|
||||
nil,
|
||||
nil,
|
||||
false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue