mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
9f0b6a5754
* Storage: refactor filtering, improve performance * added a comment to `newpathfilter` * after merge fixes
43 lines
919 B
Go
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))
|
|
})
|
|
}
|
|
}
|