[#1698] pilorama: Add a test for the empty FileName

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-08-26 13:37:03 +03:00 committed by fyrchik
parent 180e5e938f
commit ae52d53609
2 changed files with 28 additions and 0 deletions

View file

@ -312,6 +312,20 @@ func testForestTreeAddByPath(t *testing.T, s Forest) {
require.Equal(t, lm[1].Child, nodes[0])
})
})
t.Run("empty component", func(t *testing.T) {
meta := []KeyValue{
{Key: AttributeVersion, Value: []byte("XXX")},
{Key: AttributeFilename, Value: []byte{}}}
lm, err := s.TreeAddByPath(d, treeID, AttributeFilename, []string{"path", "to"}, meta)
require.NoError(t, err)
require.Equal(t, 1, len(lm))
nodes, err := s.TreeGetByPath(d.CID, treeID, AttributeFilename, []string{"path", "to", ""}, false)
require.NoError(t, err)
require.Equal(t, 1, len(nodes))
require.Equal(t, lm[0].Child, nodes[0])
})
}
func TestForest_Apply(t *testing.T) {

View file

@ -15,6 +15,20 @@ func TestMeta_Bytes(t *testing.T) {
require.Equal(t, uint64(0), m.Time)
require.Equal(t, []byte{0, 0}, m.Bytes())
})
t.Run("empty attribute value", func(t *testing.T) {
expected := Meta{
Time: 123,
Items: []KeyValue{
{"abc", []byte{1, 2, 3}},
{AttributeFilename, []byte{}},
}}
data := expected.Bytes()
var actual Meta
require.NoError(t, actual.FromBytes(data))
require.Equal(t, expected, actual)
})
t.Run("filled", func(t *testing.T) {
expected := Meta{
Time: 123,