grafana/pkg/plugins/plugins_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

2015-02-27 20:45:00 +08:00
package plugins
import (
"path/filepath"
"testing"
2015-11-27 17:04:43 +08:00
"github.com/grafana/grafana/pkg/setting"
2015-02-27 20:45:00 +08:00
. "github.com/smartystreets/goconvey/convey"
2015-11-27 17:17:27 +08:00
"gopkg.in/ini.v1"
2015-02-27 20:45:00 +08:00
)
func TestPluginScans(t *testing.T) {
2018-04-14 00:40:14 +08:00
Convey("When scanning for plugins", t, func() {
2015-11-27 17:17:27 +08:00
setting.StaticRootPath, _ = filepath.Abs("../../public/")
setting.Cfg = ini.Empty()
pm := &PluginManager{}
err := pm.Init()
2015-02-27 20:45:00 +08:00
So(err, ShouldBeNil)
2015-02-28 18:38:44 +08:00
So(len(DataSources), ShouldBeGreaterThan, 1)
2016-01-09 03:57:58 +08:00
So(len(Panels), ShouldBeGreaterThan, 1)
Convey("Should set module automatically", func() {
So(DataSources["graphite"].Module, ShouldEqual, "app/plugins/datasource/graphite/module")
})
2015-02-27 20:45:00 +08:00
})
2016-01-09 03:57:58 +08:00
Convey("When reading app plugin definition", t, func() {
setting.Cfg = ini.Empty()
sec, _ := setting.Cfg.NewSection("plugin.nginx-app")
sec.NewKey("path", "../../tests/test-app")
pm := &PluginManager{}
err := pm.Init()
2016-01-09 03:57:58 +08:00
So(err, ShouldBeNil)
So(len(Apps), ShouldBeGreaterThan, 0)
So(Apps["test-app"].Info.Logos.Large, ShouldEqual, "public/plugins/test-app/img/logo_large.png")
So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png")
2016-01-09 03:57:58 +08:00
})
2015-02-27 20:45:00 +08:00
}