plugins_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package plugins
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/grafana/grafana/pkg/setting"
  6. . "github.com/smartystreets/goconvey/convey"
  7. "gopkg.in/ini.v1"
  8. )
  9. func TestPluginScans(t *testing.T) {
  10. Convey("When scanning for plugins", t, func() {
  11. setting.StaticRootPath, _ = filepath.Abs("../../public/")
  12. setting.Cfg = ini.Empty()
  13. pm := &PluginManager{}
  14. err := pm.Init()
  15. So(err, ShouldBeNil)
  16. So(len(DataSources), ShouldBeGreaterThan, 1)
  17. So(len(Panels), ShouldBeGreaterThan, 1)
  18. Convey("Should set module automatically", func() {
  19. So(DataSources["graphite"].Module, ShouldEqual, "app/plugins/datasource/graphite/module")
  20. })
  21. })
  22. Convey("When reading app plugin definition", t, func() {
  23. setting.Cfg = ini.Empty()
  24. sec, _ := setting.Cfg.NewSection("plugin.nginx-app")
  25. sec.NewKey("path", "../../tests/test-app")
  26. pm := &PluginManager{}
  27. err := pm.Init()
  28. So(err, ShouldBeNil)
  29. So(len(Apps), ShouldBeGreaterThan, 0)
  30. So(Apps["test-app"].Info.Logos.Large, ShouldEqual, "public/plugins/test-app/img/logo_large.png")
  31. So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png")
  32. })
  33. }