storj/satellite/metainfo/metabase/iterator_test.go
Egon Elbre 402cfcb7c6 satellite/metainfo/metabase: add prefix to iterator
Change-Id: I2dd7b7917aed9def0be3f131ca60ab12f2077d83
2020-11-16 17:38:59 +02:00

47 lines
969 B
Go

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