From 5fe27ee959a0267a01d6619fea44810870fa567a Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Wed, 15 Jul 2020 20:09:03 +0200 Subject: [PATCH] Fix back-end tests on Windows (#26355) Signed-off-by: Arve Knudsen --- pkg/api/dashboard_test.go | 3 ++- pkg/plugins/manifest.go | 6 +++--- pkg/plugins/plugins_test.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/api/dashboard_test.go b/pkg/api/dashboard_test.go index f1b9a962288..7050f96ccb4 100644 --- a/pkg/api/dashboard_test.go +++ b/pkg/api/dashboard_test.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "path/filepath" "testing" "github.com/grafana/grafana/pkg/api/dtos" @@ -1002,7 +1003,7 @@ func TestDashboardApiEndpoint(t *testing.T) { dash := GetDashboardShouldReturn200WithConfig(sc, mock) Convey("Should return relative path to provisioning file", func() { - So(dash.Meta.ProvisionedExternalId, ShouldEqual, "test/dashboard1.json") + So(dash.Meta.ProvisionedExternalId, ShouldEqual, filepath.Join("test", "dashboard1.json")) }) }) diff --git a/pkg/plugins/manifest.go b/pkg/plugins/manifest.go index 45142384cea..ed137ddcce5 100644 --- a/pkg/plugins/manifest.go +++ b/pkg/plugins/manifest.go @@ -9,7 +9,7 @@ import ( "io" "io/ioutil" "os" - "path" + "path/filepath" "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/util/errutil" @@ -85,7 +85,7 @@ func readPluginManifest(body []byte) (*pluginManifest, error) { // getPluginSignatureState returns the signature state for a plugin. func getPluginSignatureState(log log.Logger, plugin *PluginBase) PluginSignature { log.Debug("Getting signature state of plugin", "plugin", plugin.Id) - manifestPath := path.Join(plugin.PluginDir, "MANIFEST.txt") + manifestPath := filepath.Join(plugin.PluginDir, "MANIFEST.txt") byteValue, err := ioutil.ReadFile(manifestPath) if err != nil || len(byteValue) < 10 { @@ -106,7 +106,7 @@ func getPluginSignatureState(log log.Logger, plugin *PluginBase) PluginSignature log.Debug("Verifying contents of plugin manifest", "plugin", plugin.Id) for p, hash := range manifest.Files { // Open the file - fp := path.Join(plugin.PluginDir, p) + fp := filepath.Join(plugin.PluginDir, p) f, err := os.Open(fp) if err != nil { return PluginSignatureModified diff --git a/pkg/plugins/plugins_test.go b/pkg/plugins/plugins_test.go index 94a4d1fd4ea..54cbf22e18d 100644 --- a/pkg/plugins/plugins_test.go +++ b/pkg/plugins/plugins_test.go @@ -160,7 +160,7 @@ func TestPluginManager_Init(t *testing.T) { err := pm.Init() require.NoError(t, err) - assert.Empty(t, pm.scanningErrors) + require.Empty(t, pm.scanningErrors) assert.Equal(t, []string{"gel"}, fm.registeredPlugins) }) }