mirror of https://github.com/grafana/grafana
parent
2a766c6a04
commit
f6414ea2b2
@ -0,0 +1,37 @@ |
||||
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) |
||||
} |
||||
} |
Loading…
Reference in new issue