From 8a27483b81f460405e5704bc56d56864affa620f Mon Sep 17 00:00:00 2001 From: Andre Harms Date: Tue, 10 Feb 2026 13:58:06 +0100 Subject: [PATCH] fix: tests --- .../postgresflexalpha/database/mapper_test.go | 7 ++++++- .../services/postgresflexalpha/user/mapper_test.go | 5 ++++- .../services/sqlserverflexalpha/user/resource.go | 2 ++ stackit/internal/wait/postgresflexalpha/wait.go | 14 ++++++++------ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/stackit/internal/services/postgresflexalpha/database/mapper_test.go b/stackit/internal/services/postgresflexalpha/database/mapper_test.go index a2f18c12..97212237 100644 --- a/stackit/internal/services/postgresflexalpha/database/mapper_test.go +++ b/stackit/internal/services/postgresflexalpha/database/mapper_test.go @@ -34,7 +34,12 @@ func TestMapFields(t *testing.T) { Name: utils.Ptr("my-db"), Owner: utils.Ptr("\"my-owner\""), }, - model: &dataSourceModel{}, + model: &dataSourceModel{ + DatabaseModel: datasource.DatabaseModel{ + ProjectId: types.StringValue("my-project"), + InstanceId: types.StringValue("my-instance"), + }, + }, region: "eu01", }, expected: expected{ diff --git a/stackit/internal/services/postgresflexalpha/user/mapper_test.go b/stackit/internal/services/postgresflexalpha/user/mapper_test.go index 6eeff9f0..37410b19 100644 --- a/stackit/internal/services/postgresflexalpha/user/mapper_test.go +++ b/stackit/internal/services/postgresflexalpha/user/mapper_test.go @@ -164,6 +164,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ + Id: types.Int64Value(1), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -185,6 +186,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ + Id: types.Int64Value(1), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -193,7 +195,7 @@ func TestMapFieldsCreate(t *testing.T) { Password: types.StringNull(), Region: types.StringValue(testRegion), Status: types.StringValue("status"), - ConnectionString: types.StringValue("connection_string"), + ConnectionString: types.StringNull(), }, true, }, @@ -206,6 +208,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ + Id: types.Int64Value(1), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), diff --git a/stackit/internal/services/sqlserverflexalpha/user/resource.go b/stackit/internal/services/sqlserverflexalpha/user/resource.go index 41e6e1c5..a24cad8b 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/resource.go +++ b/stackit/internal/services/sqlserverflexalpha/user/resource.go @@ -416,6 +416,7 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res return fmt.Errorf("user id not present") } userId := *user.Id + model.Id = types.Int64Value(userId) model.UserId = types.Int64Value(userId) model.Username = types.StringPointerValue(user.Username) @@ -467,6 +468,7 @@ func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceMode return fmt.Errorf("user id not present") } + model.Id = types.Int64Value(userId) model.UserId = types.Int64Value(userId) model.Username = types.StringPointerValue(user.Username) diff --git a/stackit/internal/wait/postgresflexalpha/wait.go b/stackit/internal/wait/postgresflexalpha/wait.go index 5177e6f1..c490b605 100644 --- a/stackit/internal/wait/postgresflexalpha/wait.go +++ b/stackit/internal/wait/postgresflexalpha/wait.go @@ -67,9 +67,11 @@ func CreateInstanceWaitHandler( if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { return false, nil, nil } - tflog.Debug(ctx, "waiting for instance ready", map[string]interface{}{ - "status": *s.Status, - }) + tflog.Debug( + ctx, "waiting for instance ready", map[string]interface{}{ + "status": *s.Status, + }, + ) switch *s.Status { default: return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status) @@ -118,13 +120,13 @@ func CreateInstanceWaitHandler( instanceCreated = true instanceGetResponse = s case InstanceStateSuccess: - if *s.Network.AccessScope == "SNA" { - if s.Network == nil || s.Network.InstanceAddress == nil { + if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" { + if s.Network.InstanceAddress == nil { tflog.Warn(ctx, "Waiting for instance_address") return false, nil, nil } if s.Network.RouterAddress == nil { - tflog.Info(ctx, "Waiting for router_address") + tflog.Warn(ctx, "Waiting for router_address") return false, nil, nil } }