storj/satellite/metainfo/metabase/iterator_util_test.go
Egon Elbre 261a4c1c09 satellite/metainfo/metabase: fix iterator boundaries
Currently the old encrypted keys may not match the path component
encoding. Change the iterator such that the prefixes handle arbitrary
byte sequences.

Change-Id: I0a50049f4ef9887e1c4df6f9692f967a054430eb
2021-02-28 21:19:51 +02:00

30 lines
589 B
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package metabase
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPrefixLimit(t *testing.T) {
unchanged := ObjectKey("unchanged")
_ = prefixLimit(unchanged)
require.Equal(t, ObjectKey("unchanged"), unchanged)
tests := []struct{ in, exp ObjectKey }{
{"", ""},
{"a", "b"},
{"\xF1", "\xF2"},
{"\xFF", "\xFF\x00"},
}
for _, test := range tests {
require.Equal(t, test.exp, prefixLimit(test.in))
if test.in != "" {
require.True(t, lessKey(test.in, test.exp))
}
}
}