1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 18:20:33 +09:00

GO-5294 Fix test

This commit is contained in:
kirillston 2025-03-17 19:20:57 +03:00
parent 72b82e53b4
commit c7d0f0aade
No known key found for this signature in database
GPG key ID: BE4BF014F0ECDFE8
2 changed files with 4 additions and 5 deletions

View file

@ -187,15 +187,16 @@ func buildDiffDetails(origin, current *domain.Details, isSystem bool) *domain.De
diff, _ := domain.StructDiff(current, origin)
diff = diff.CopyOnlyKeys(filterKeys...)
if cannotApplyPluralName(isSystem, diff) {
if cannotApplyPluralName(isSystem, current, origin) {
diff.Delete(bundle.RelationKeyName)
diff.Delete(bundle.RelationKeyPluralName)
}
return diff
}
func cannotApplyPluralName(isSystem bool, diff *domain.Details) bool {
return !isSystem && diff.Has(bundle.RelationKeyName)
func cannotApplyPluralName(isSystem bool, current, origin *domain.Details) bool {
// we cannot set plural name to custom types with custom name
return !isSystem && current.GetString(bundle.RelationKeyName) != origin.GetString(bundle.RelationKeyName)
}
func checkRelationFormatObjectTypes(

View file

@ -356,7 +356,6 @@ func TestBuildDiffDetails(t *testing.T) {
}), true)
assert.Equal(t, "Pages", diff.GetString(bundle.RelationKeyPluralName))
assert.Equal(t, "Page", diff.GetString(bundle.RelationKeyName))
})
t.Run("new name is applied to custom types, if name was not modified", func(t *testing.T) {
@ -368,7 +367,6 @@ func TestBuildDiffDetails(t *testing.T) {
}), false)
assert.Equal(t, "Projects", diff.GetString(bundle.RelationKeyPluralName))
assert.Equal(t, "Project", diff.GetString(bundle.RelationKeyName))
})
t.Run("new name is NOT applied to custom types, if name was modified", func(t *testing.T) {