From d9a5007c72ef5515ab4b6ee9edf441e8b9856e75 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 2 Nov 2020 11:01:55 +0300 Subject: [PATCH] [#137] metabase: Add unit test for a nonexistent attribute Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/metabase/db_test.go | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index 068c6d4b3..808d0f588 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -239,3 +239,24 @@ func releaseDB(db *DB) { db.Close() os.Remove(db.Path()) } + +func TestSelectNonExistentAttributes(t *testing.T) { + db := newDB(t) + + defer releaseDB(db) + + obj := object.NewRaw() + obj.SetID(testOID()) + obj.SetContainerID(testCID()) + + require.NoError(t, db.Put(obj.Object())) + + fs := objectSDK.SearchFilters{} + + // add filter by non-existent attribute + fs.AddFilter("key", "value", objectSDK.MatchStringEqual) + + res, err := db.Select(fs) + require.NoError(t, err) + require.Empty(t, res) +}