forked from TrueCloudLab/frostfs-api-go
[#231] object/search: Implement method to add search filter by type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
53e2756762
commit
f0ebe80a78
2 changed files with 22 additions and 0 deletions
|
@ -240,3 +240,8 @@ func (f *SearchFilters) AddObjectIDFilter(m SearchMatchType, id *ID) {
|
||||||
func (f *SearchFilters) AddSplitIDFilter(m SearchMatchType, id *SplitID) {
|
func (f *SearchFilters) AddSplitIDFilter(m SearchMatchType, id *SplitID) {
|
||||||
f.addReservedFilter(m, fKeySplitID, id)
|
f.addReservedFilter(m, fKeySplitID, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTypeFilter adds filter by object type.
|
||||||
|
func (f *SearchFilters) AddTypeFilter(m SearchMatchType, typ Type) {
|
||||||
|
f.addReservedFilter(m, fKeyType, typ)
|
||||||
|
}
|
||||||
|
|
|
@ -140,3 +140,20 @@ func TestSearchFilters_AddSplitIDFilter(t *testing.T) {
|
||||||
require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType())
|
require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSearchFilters_AddTypeFilter(t *testing.T) {
|
||||||
|
typ := object.TypeTombstone
|
||||||
|
|
||||||
|
fs := new(object.SearchFilters)
|
||||||
|
fs.AddTypeFilter(object.MatchStringEqual, typ)
|
||||||
|
|
||||||
|
t.Run("v2", func(t *testing.T) {
|
||||||
|
fsV2 := fs.ToV2()
|
||||||
|
|
||||||
|
require.Len(t, fsV2, 1)
|
||||||
|
|
||||||
|
require.Equal(t, v2object.FilterHeaderObjectType, fsV2[0].GetKey())
|
||||||
|
require.Equal(t, typ.String(), fsV2[0].GetValue())
|
||||||
|
require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue