From ece6ee8f285209e37cf491708d6403d391c581a8 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Tue, 17 Mar 2026 15:31:39 +0100 Subject: [PATCH] fix: fix mapper test [skip ci] --- .../postgresflexalpha/user/mapper_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stackit/internal/services/postgresflexalpha/user/mapper_test.go b/stackit/internal/services/postgresflexalpha/user/mapper_test.go index c45948ee..f8c01fc2 100644 --- a/stackit/internal/services/postgresflexalpha/user/mapper_test.go +++ b/stackit/internal/services/postgresflexalpha/user/mapper_test.go @@ -1,6 +1,7 @@ package postgresflexalpha import ( + "fmt" "testing" "github.com/google/go-cmp/cmp" @@ -165,7 +166,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -187,7 +188,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -209,7 +210,7 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -249,6 +250,7 @@ func TestMapFieldsCreate(t *testing.T) { tt.description, func(t *testing.T) { state := &resourceModel{ ProjectId: tt.expected.ProjectId, + Region: types.StringValue(testRegion), InstanceId: tt.expected.InstanceId, } @@ -286,7 +288,7 @@ func TestMapFields(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(int64(1)), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -311,7 +313,7 @@ func TestMapFields(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -339,7 +341,7 @@ func TestMapFields(t *testing.T) { }, testRegion, resourceModel{ - Id: types.StringValue("1"), + Id: types.StringValue(fmt.Sprintf("%s,%s,%s,%d", "pid", testRegion, "iid", 1)), UserId: types.Int64Value(1), InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), @@ -379,6 +381,7 @@ func TestMapFields(t *testing.T) { state := &resourceModel{ ProjectId: tt.expected.ProjectId, InstanceId: tt.expected.InstanceId, + Region: types.StringValue(tt.region), } err := mapResourceFields(tt.input, state, tt.region) if !tt.isValid && err == nil { @@ -388,7 +391,7 @@ func TestMapFields(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(state, &tt.expected) + diff := cmp.Diff(&tt.expected, state) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -476,7 +479,7 @@ func TestToCreatePayload(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(output, tt.expected) + diff := cmp.Diff(tt.expected, output) if diff != "" { t.Fatalf("Data does not match: %s", diff) }