[#66] transformer: Extend tests

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-03 11:09:12 +03:00
parent 29b188db57
commit c42a6119ff
2 changed files with 16 additions and 3 deletions

View file

@ -81,10 +81,10 @@ func (s *payloadSizeLimiter) initialize() {
// initialize parent object once (after 1st object)
if ln == 1 {
s.parent = fromObject(s.current)
s.parentHashers = append(s.parentHashers[:0], s.currentHashers...)
// return source attributes
s.parent.ResetRelations()
s.parent.SetSignature(nil)
s.parent.SetAttributes(s.parAttrs...)
s.parentHashers = append(s.parentHashers[:0], s.currentHashers...)
}
// set previous object to the last previous identifier

View file

@ -55,15 +55,28 @@ func TestTransformer(t *testing.T) {
require.Equal(t, h[:], cs.Value())
}
require.True(t, tt.objects[i].VerifyIDSignature())
switch i {
case 0, 1:
require.EqualValues(t, maxSize, len(payload))
require.Nil(t, tt.objects[i].Parent())
case 2:
require.EqualValues(t, maxSize/2, len(payload))
parent := tt.objects[i].Parent()
require.NotNil(t, parent)
require.Nil(t, parent.SplitID())
require.True(t, parent.VerifyIDSignature())
case 3:
parID, ok := tt.objects[i].ParentID()
require.True(t, ok)
require.Equal(t, ids.ParentID, &parID)
children := tt.objects[i].Children()
for j := 0; j < i; j++ {
id, ok := tt.objects[j].ID()
require.True(t, ok)
require.Equal(t, id, children[j])
}
}
}
require.Equal(t, expectedPayload, actualPayload)