mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
use absolute path when getting grafana path; add test for directory (#36001)
This commit is contained in:
@@ -29,3 +29,17 @@ func TestExists_Existent(t *testing.T) {
|
||||
|
||||
require.True(t, exists)
|
||||
}
|
||||
|
||||
func TestExists_Dir(t *testing.T) {
|
||||
f, err := ioutil.TempDir("", "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
err := os.Remove(f)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
exists, err := Exists(f)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.True(t, exists)
|
||||
}
|
||||
|
@@ -121,13 +121,20 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
found := false
|
||||
for i := 0; i < 20; i++ {
|
||||
rootDir = filepath.Join(rootDir, "..")
|
||||
exists, err := fs.Exists(filepath.Join(rootDir, "public", "views"))
|
||||
|
||||
dir, err := filepath.Abs(rootDir)
|
||||
require.NoError(t, err)
|
||||
|
||||
exists, err := fs.Exists(filepath.Join(dir, "public", "views"))
|
||||
require.NoError(t, err)
|
||||
|
||||
if exists {
|
||||
rootDir = dir
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
require.True(t, found, "Couldn't detect project root directory")
|
||||
|
||||
cfgDir := filepath.Join(tmpDir, "conf")
|
||||
|
Reference in New Issue
Block a user