fix: refactor tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m27s
CI Workflow / CI run tests (pull_request) Failing after 4m54s
CI Workflow / CI run build and linting (pull_request) Failing after 4m39s
CI Workflow / Code coverage report (pull_request) Has been skipped

This commit is contained in:
Marcel S. Henselin 2026-03-09 11:03:29 +01:00
parent 826bb5b36a
commit c7260e04e2
19 changed files with 521 additions and 938 deletions

View file

@ -28,13 +28,13 @@ func TestMapDataSourceFields(t *testing.T) {
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Username: types.StringValue(""),
Roles: types.List(types.SetNull(types.StringType)),
Host: types.StringNull(),
Port: types.Int64Null(),
Host: types.StringValue(""),
Port: types.Int64Value(0),
Region: types.StringValue(testRegion),
Status: types.StringNull(),
DefaultDatabase: types.StringNull(),
Status: types.StringValue(""),
DefaultDatabase: types.StringValue(""),
},
true,
},
@ -93,15 +93,17 @@ func TestMapDataSourceFields(t *testing.T) {
},
testRegion,
dataSourceModel{
Id: types.StringValue("pid,region,iid,1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Host: types.StringNull(),
Port: types.Int64Value(2123456789),
Region: types.StringValue(testRegion),
Id: types.StringValue("pid,region,iid,1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringValue(""),
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Host: types.StringValue(""),
Port: types.Int64Value(2123456789),
Region: types.StringValue(testRegion),
DefaultDatabase: types.StringValue(""),
Status: types.StringValue(""),
},
true,
},
@ -165,28 +167,31 @@ func TestMapFieldsCreate(t *testing.T) {
{
"default_values",
&v3alpha1api.CreateUserResponse{
Id: (int64(1)),
Password: (""),
Id: int64(1),
Password: "xy",
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Roles: types.List(types.SetNull(types.StringType)),
Password: types.StringValue(""),
Host: types.StringNull(),
Port: types.Int64Null(),
Region: types.StringValue(testRegion),
Id: types.Int64Value(1),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringValue(""),
Roles: types.List(types.SetNull(types.StringType)),
Password: types.StringValue("xy"),
Host: types.StringValue(""),
Port: types.Int64Value(0),
Region: types.StringValue(testRegion),
DefaultDatabase: types.StringValue(""),
Status: types.StringValue(""),
Uri: types.StringValue(""),
},
true,
},
{
"simple_values",
&v3alpha1api.CreateUserResponse{
Id: (int64(2)),
Id: int64(2),
Roles: []string{
"role_2",
"role_1",
@ -198,6 +203,7 @@ func TestMapFieldsCreate(t *testing.T) {
Port: int32(1234),
Status: "status",
DefaultDatabase: "default_db",
Uri: "myURI",
},
testRegion,
resourceModel{
@ -221,6 +227,7 @@ func TestMapFieldsCreate(t *testing.T) {
Region: types.StringValue(testRegion),
Status: types.StringValue("status"),
DefaultDatabase: types.StringValue("default_db"),
Uri: types.StringValue("myURI"),
},
true,
},
@ -230,7 +237,7 @@ func TestMapFieldsCreate(t *testing.T) {
Id: int64(3),
Roles: []string{},
Username: "",
Password: "",
Password: "xy",
Host: "",
Port: int32(256789),
},
@ -240,14 +247,15 @@ func TestMapFieldsCreate(t *testing.T) {
UserId: types.Int64Value(3),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Password: types.StringValue(""),
Host: types.StringNull(),
Port: types.Int64Value(2123456789),
Username: types.StringValue(""),
Roles: types.ListNull(types.StringType),
Password: types.StringValue("xy"),
Host: types.StringValue(""),
Port: types.Int64Value(256789),
Region: types.StringValue(testRegion),
DefaultDatabase: types.StringNull(),
Status: types.StringNull(),
DefaultDatabase: types.StringValue(""),
Status: types.StringValue(""),
Uri: types.StringValue(""),
},
true,
},
@ -325,10 +333,10 @@ func TestMapFields(t *testing.T) {
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Username: types.StringValue(""),
Roles: types.List(types.SetNull(types.StringType)),
Host: types.StringNull(),
Port: types.Int64Null(),
Host: types.StringValue(""),
Port: types.Int64Value(0),
Region: types.StringValue(testRegion),
},
true,
@ -382,9 +390,9 @@ func TestMapFields(t *testing.T) {
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
Username: types.StringNull(),
Username: types.StringValue(""),
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
Host: types.StringNull(),
Host: types.StringValue(""),
Port: types.Int64Value(2123456789),
Region: types.StringValue(testRegion),
},
@ -477,7 +485,7 @@ func TestToCreatePayload(t *testing.T) {
{
"null_fields_and_int_conversions",
&resourceModel{
Username: types.StringNull(),
Username: types.StringValue(""),
},
[]string{
"",