mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
f6414ea2b2
Ref #43080
38 lines
637 B
Go
38 lines
637 B
Go
package util
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCleanRelativePath(t *testing.T) {
|
|
testcases := []struct {
|
|
input string
|
|
expectedPath string
|
|
}{
|
|
{
|
|
input: "",
|
|
expectedPath: ".",
|
|
},
|
|
{
|
|
input: "/test/test.txt",
|
|
expectedPath: "test/test.txt",
|
|
},
|
|
{
|
|
input: "../../test/test.txt",
|
|
expectedPath: "test/test.txt",
|
|
},
|
|
{
|
|
input: "./../test/test.txt",
|
|
expectedPath: "test/test.txt",
|
|
},
|
|
}
|
|
|
|
for _, tt := range testcases {
|
|
path, err := CleanRelativePath(tt.input)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, tt.expectedPath, path)
|
|
}
|
|
}
|