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