mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 07:35:45 -06:00
* refactoring store interface and init flow * fix import * fix linter * refactor resource calling * load with class * re-order args * fix tests * fix linter * remove old creator * add custom config struct * fix some tests * cleanup * fix * tackle plugins * fix linter * refactor and fix test * add connect failure error * add fix for azure, cloud monitoring and test data * restructure * remove unused err * add fake tracer for test * fix grafana ds plugin
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package grafanads
|
|
|
|
import (
|
|
"encoding/json"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana-plugin-sdk-go/experimental"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func asJSON(v interface{}) json.RawMessage {
|
|
b, _ := json.Marshal(v)
|
|
return b
|
|
}
|
|
|
|
func TestReadFolderListing(t *testing.T) {
|
|
ds := newService(&setting.Cfg{StaticRootPath: "../../../public"})
|
|
dr := ds.doListQuery(backend.DataQuery{
|
|
QueryType: "x",
|
|
JSON: asJSON(listQueryModel{
|
|
Path: "testdata",
|
|
}),
|
|
})
|
|
err := experimental.CheckGoldenDataResponse(path.Join("testdata", "list.golden.txt"), &dr, true)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestReadCSVFile(t *testing.T) {
|
|
ds := newService(&setting.Cfg{StaticRootPath: "../../../public"})
|
|
dr := ds.doReadQuery(backend.DataQuery{
|
|
QueryType: "x",
|
|
JSON: asJSON(readQueryModel{
|
|
Path: "testdata/js_libraries.csv",
|
|
}),
|
|
})
|
|
err := experimental.CheckGoldenDataResponse(path.Join("testdata", "jslib.golden.txt"), &dr, true)
|
|
require.NoError(t, err)
|
|
}
|