mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Make file system path handling in tests OS agnostic (#79651)
* make path handling OS agnostic * PR feedback * fix input for test case
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -16,16 +17,17 @@ func TestCleanRelativePath(t *testing.T) {
|
||||
expectedPath: ".",
|
||||
},
|
||||
{
|
||||
input: "/test/test.txt",
|
||||
expectedPath: "test/test.txt",
|
||||
input: filepath.Join(string(filepath.Separator), "test", "test.txt"),
|
||||
expectedPath: filepath.Join("test", "test.txt"),
|
||||
},
|
||||
{
|
||||
input: "../../test/test.txt",
|
||||
expectedPath: "test/test.txt",
|
||||
input: filepath.Join("..", "..", "test", "test.txt"),
|
||||
expectedPath: filepath.Join("test", "test.txt"),
|
||||
},
|
||||
{
|
||||
input: "./../test/test.txt",
|
||||
expectedPath: "test/test.txt",
|
||||
// since filepath.Join will remove the leading dot, we need to build the path manually
|
||||
input: "." + string(filepath.Separator) + filepath.Join("..", "test", "test.txt"),
|
||||
expectedPath: filepath.Join("test", "test.txt"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user