feat: more_tests #85

Merged
marcel.henselin merged 26 commits from feat/more_tests into alpha 2026-03-17 15:02:08 +00:00
Showing only changes of commit ece6ee8f28 - Show all commits

View file

@ -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)
}