fix: fix mapper test - mapping does not touch id field
This commit is contained in:
parent
4c5f392e40
commit
8420ef52e4
2 changed files with 5 additions and 5 deletions
|
|
@ -64,21 +64,21 @@ func mapResourceFields(source *v3alpha1api.GetDatabaseResponse, model *resourceM
|
||||||
return fmt.Errorf("model input is nil")
|
return fmt.Errorf("model input is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseId int64
|
var databaseID int64
|
||||||
if model.DatabaseId.ValueInt64() != 0 {
|
if model.DatabaseId.ValueInt64() != 0 {
|
||||||
if source.Id != 0 {
|
if source.Id != 0 {
|
||||||
if model.DatabaseId.ValueInt64() != int64(source.Id) {
|
if model.DatabaseId.ValueInt64() != int64(source.Id) {
|
||||||
return fmt.Errorf("retrieved ID does not match known ID")
|
return fmt.Errorf("retrieved ID does not match known ID")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
databaseId = model.DatabaseId.ValueInt64()
|
databaseID = model.DatabaseId.ValueInt64()
|
||||||
} else if source.Id != 0 {
|
} else if source.Id != 0 {
|
||||||
databaseId = int64(source.Id)
|
databaseID = int64(source.Id)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("database id not present")
|
return fmt.Errorf("database id not present")
|
||||||
}
|
}
|
||||||
|
|
||||||
model.DatabaseId = types.Int64Value(databaseId)
|
model.DatabaseId = types.Int64Value(databaseID)
|
||||||
model.Name = types.StringValue(source.GetName())
|
model.Name = types.StringValue(source.GetName())
|
||||||
model.Owner = types.StringValue(cleanString(source.Owner))
|
model.Owner = types.StringValue(cleanString(source.Owner))
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ func TestMapResourceFields(t *testing.T) {
|
||||||
},
|
},
|
||||||
expected: expected{
|
expected: expected{
|
||||||
model: &resourceModel{
|
model: &resourceModel{
|
||||||
Id: types.StringValue("1"),
|
Id: types.StringNull(),
|
||||||
Name: types.StringValue("my-db"),
|
Name: types.StringValue("my-db"),
|
||||||
Owner: types.StringValue("my-owner"),
|
Owner: types.StringValue("my-owner"),
|
||||||
DatabaseId: types.Int64Value(1),
|
DatabaseId: types.Int64Value(1),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue