grafana/pkg/infra/filestorage/wrapper_test.go
Artur Wierzbicki 9f0b6a5754
Storage: refactor filtering, improve performance (#47403)
* Storage: refactor filtering, improve performance

* added a comment to `newpathfilter`

* after merge fixes
2022-04-21 23:27:43 +04:00

43 lines
919 B
Go

package filestorage
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestFilestorage_getParentFolderPath(t *testing.T) {
var tests = []struct {
name string
path string
expected string
}{
{
name: "should return empty path if path has a single part - relative, suffix",
path: "ab/",
expected: "",
},
{
name: "should return empty path if path has a single part - relative, no suffix",
path: "ab",
expected: "",
},
{
name: "should return root if path has a single part - abs, no suffix",
path: "/public",
expected: Delimiter,
},
{
name: "should return root if path has a single part - abs, suffix",
path: "/public/",
expected: Delimiter,
},
}
for _, tt := range tests {
t.Run(fmt.Sprintf(tt.name), func(t *testing.T) {
require.Equal(t, tt.expected, getParentFolderPath(tt.path))
})
}
}