fix: fix mapper test - mapping does not touch id field

This commit is contained in:
Marcel S. Henselin 2026-03-17 15:22:58 +01:00
parent 4c5f392e40
commit 8420ef52e4
2 changed files with 5 additions and 5 deletions

View file

@ -64,21 +64,21 @@ func mapResourceFields(source *v3alpha1api.GetDatabaseResponse, model *resourceM
return fmt.Errorf("model input is nil")
}
var databaseId int64
var databaseID int64
if model.DatabaseId.ValueInt64() != 0 {
if source.Id != 0 {
if model.DatabaseId.ValueInt64() != int64(source.Id) {
return fmt.Errorf("retrieved ID does not match known ID")
}
}
databaseId = model.DatabaseId.ValueInt64()
databaseID = model.DatabaseId.ValueInt64()
} else if source.Id != 0 {
databaseId = int64(source.Id)
databaseID = int64(source.Id)
} else {
return fmt.Errorf("database id not present")
}
model.DatabaseId = types.Int64Value(databaseId)
model.DatabaseId = types.Int64Value(databaseID)
model.Name = types.StringValue(source.GetName())
model.Owner = types.StringValue(cleanString(source.Owner))
return nil

View file

@ -160,7 +160,7 @@ func TestMapResourceFields(t *testing.T) {
},
expected: expected{
model: &resourceModel{
Id: types.StringValue("1"),
Id: types.StringNull(),
Name: types.StringValue("my-db"),
Owner: types.StringValue("my-owner"),
DatabaseId: types.Int64Value(1),