2022-04-08 13:56:38 +02:00
|
|
|
//go:build linux || darwin
|
|
|
|
|
// +build linux darwin
|
2018-05-21 09:03:32 +02:00
|
|
|
|
|
|
|
|
package dashboards
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2019-05-13 14:45:54 +08:00
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
2021-03-12 11:51:02 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2018-05-21 09:03:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
symlinkedFolder = "testdata/test-dashboards/symlink"
|
|
|
|
|
)
|
|
|
|
|
|
2020-06-01 17:11:25 +02:00
|
|
|
func TestProvisionedSymlinkedFolder(t *testing.T) {
|
2020-04-16 05:46:20 +02:00
|
|
|
cfg := &config{
|
2018-05-21 09:03:32 +02:00
|
|
|
Name: "Default",
|
|
|
|
|
Type: "file",
|
2020-04-16 05:46:20 +02:00
|
|
|
OrgID: 1,
|
2018-05-21 09:03:32 +02:00
|
|
|
Folder: "",
|
|
|
|
|
Options: map[string]interface{}{"path": symlinkedFolder},
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 13:56:38 +02:00
|
|
|
reader, err := NewDashboardFileReader(cfg, log.New("test-logger"), nil, nil)
|
2021-07-21 19:52:41 +04:00
|
|
|
if err != nil {
|
|
|
|
|
t.Error("expected err to be nil")
|
|
|
|
|
}
|
2018-05-21 09:03:32 +02:00
|
|
|
|
2020-04-15 08:12:52 +02:00
|
|
|
want, err := filepath.Abs(containingID)
|
2021-03-12 11:51:02 +01:00
|
|
|
require.NoError(t, err)
|
2018-05-21 09:03:32 +02:00
|
|
|
|
2019-04-30 13:32:18 +02:00
|
|
|
resolvedPath := reader.resolvedPath()
|
2021-03-12 11:51:02 +01:00
|
|
|
assert.Equal(t, want, resolvedPath)
|
2018-05-21 09:03:32 +02:00
|
|
|
}
|