plugins_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package plugins
  2. import (
  3. "context"
  4. "path/filepath"
  5. "testing"
  6. "github.com/grafana/grafana/pkg/setting"
  7. . "github.com/smartystreets/goconvey/convey"
  8. "gopkg.in/ini.v1"
  9. )
  10. func TestPluginScans(t *testing.T) {
  11. Convey("When scaning for plugins", t, func() {
  12. setting.StaticRootPath, _ = filepath.Abs("../../public/")
  13. setting.Cfg = ini.Empty()
  14. err := Init(context.TODO())
  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. err := Init(context.TODO())
  27. So(err, ShouldBeNil)
  28. So(len(Apps), ShouldBeGreaterThan, 0)
  29. So(Apps["test-app"].Info.Logos.Large, ShouldEqual, "public/plugins/test-app/img/logo_large.png")
  30. So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png")
  31. })
  32. }