[#233] Make search by attribute as it is
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
9cb9d14146
commit
0b9b23e67c
3 changed files with 3 additions and 130 deletions
|
@ -427,90 +427,6 @@ func TestFindObjectByAttribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNeedSearchByFileName(t *testing.T) {
|
||||
hc := prepareHandlerContext(t)
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
attrKey string
|
||||
attrVal string
|
||||
additionalSearch bool
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "need search - not contains slash",
|
||||
attrKey: attrFilePath,
|
||||
attrVal: "cat.png",
|
||||
additionalSearch: true,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "need search - single lead slash",
|
||||
attrKey: attrFilePath,
|
||||
attrVal: "/cat.png",
|
||||
additionalSearch: true,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "don't need search - single slash but not lead",
|
||||
attrKey: attrFilePath,
|
||||
attrVal: "cats/cat.png",
|
||||
additionalSearch: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "don't need search - more one slash",
|
||||
attrKey: attrFilePath,
|
||||
attrVal: "/cats/cat.png",
|
||||
additionalSearch: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "don't need search - incorrect attribute key",
|
||||
attrKey: attrFileName,
|
||||
attrVal: "cat.png",
|
||||
additionalSearch: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "don't need search - additional search disabled",
|
||||
attrKey: attrFilePath,
|
||||
attrVal: "cat.png",
|
||||
additionalSearch: false,
|
||||
expected: false,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
hc.cfg.additionalFilenameSearch = tc.additionalSearch
|
||||
|
||||
res := hc.h.needSearchByFileName(tc.attrKey, tc.attrVal)
|
||||
require.Equal(t, tc.expected, res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareFileName(t *testing.T) {
|
||||
fileName := "/cat.jpg"
|
||||
expected := "cat.jpg"
|
||||
actual := prepareFileName(fileName)
|
||||
require.Equal(t, expected, actual)
|
||||
|
||||
fileName = "cat.jpg"
|
||||
actual = prepareFileName(fileName)
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestPrepareFilePath(t *testing.T) {
|
||||
filePath := "cat.jpg"
|
||||
expected := "/cat.jpg"
|
||||
actual := prepareFilePath(filePath)
|
||||
require.Equal(t, expected, actual)
|
||||
|
||||
filePath = "/cat.jpg"
|
||||
actual = prepareFilePath(filePath)
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func prepareUploadRequest(ctx context.Context, bucket, content string) (*fasthttp.RequestCtx, error) {
|
||||
r := new(fasthttp.RequestCtx)
|
||||
utils.SetContextToRequest(ctx, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue