plugins_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 scaning for plugins", t, func() {
  11. setting.StaticRootPath, _ = filepath.Abs("../../public/")
  12. setting.Cfg = ini.Empty()
  13. _, err := Init()
  14. So(err, ShouldBeNil)
  15. So(len(DataSources), ShouldBeGreaterThan, 1)
  16. So(len(Panels), ShouldBeGreaterThan, 1)
  17. Convey("Should set module automatically", func() {
  18. So(DataSources["graphite"].Module, ShouldEqual, "app/plugins/datasource/graphite/module")
  19. })
  20. })
  21. Convey("When reading app plugin definition", t, func() {
  22. setting.Cfg = ini.Empty()
  23. sec, _ := setting.Cfg.NewSection("plugin.nginx-app")
  24. sec.NewKey("path", "../../tests/test-app")
  25. _, err := Init()
  26. So(err, ShouldBeNil)
  27. So(len(Apps), ShouldBeGreaterThan, 0)
  28. So(Apps["test-app"].Info.Logos.Large, ShouldEqual, "public/plugins/test-app/img/logo_large.png")
  29. So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png")
  30. })
  31. }