2015-02-27 06:45:00 -06:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2015-11-27 03:04:43 -06:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
2015-02-27 06:45:00 -06:00
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
2015-11-27 03:17:27 -06:00
|
|
|
"gopkg.in/ini.v1"
|
2015-02-27 06:45:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPluginScans(t *testing.T) {
|
|
|
|
|
2018-04-13 11:40:14 -05:00
|
|
|
Convey("When scanning for plugins", t, func() {
|
2015-11-27 03:17:27 -06:00
|
|
|
setting.StaticRootPath, _ = filepath.Abs("../../public/")
|
2018-04-30 09:21:04 -05:00
|
|
|
setting.Raw = ini.Empty()
|
2018-04-27 08:11:55 -05:00
|
|
|
|
2020-03-25 06:25:39 -05:00
|
|
|
pm := &PluginManager{
|
|
|
|
Cfg: &setting.Cfg{
|
|
|
|
FeatureToggles: map[string]bool{},
|
|
|
|
},
|
|
|
|
}
|
2018-04-27 08:11:55 -05:00
|
|
|
err := pm.Init()
|
2015-02-27 06:45:00 -06:00
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
2015-02-28 04:38:44 -06:00
|
|
|
So(len(DataSources), ShouldBeGreaterThan, 1)
|
2016-01-08 13:57:58 -06:00
|
|
|
So(len(Panels), ShouldBeGreaterThan, 1)
|
2016-01-09 16:34:20 -06:00
|
|
|
|
|
|
|
Convey("Should set module automatically", func() {
|
|
|
|
So(DataSources["graphite"].Module, ShouldEqual, "app/plugins/datasource/graphite/module")
|
|
|
|
})
|
2015-02-27 06:45:00 -06:00
|
|
|
})
|
2016-01-08 13:57:58 -06:00
|
|
|
|
|
|
|
Convey("When reading app plugin definition", t, func() {
|
2020-03-25 06:25:39 -05:00
|
|
|
pm := &PluginManager{
|
|
|
|
Cfg: &setting.Cfg{
|
|
|
|
FeatureToggles: map[string]bool{},
|
2020-04-14 11:04:27 -05:00
|
|
|
PluginSettings: setting.PluginSettings{
|
|
|
|
"nginx-app": map[string]string{
|
|
|
|
"path": "testdata/test-app",
|
|
|
|
},
|
|
|
|
},
|
2020-03-25 06:25:39 -05:00
|
|
|
},
|
|
|
|
}
|
2020-04-14 11:04:27 -05:00
|
|
|
err := pm.Init()
|
2016-01-08 13:57:58 -06:00
|
|
|
So(err, ShouldBeNil)
|
2016-03-10 12:57:48 -06:00
|
|
|
|
2019-10-11 14:02:15 -05:00
|
|
|
So(len(Apps), ShouldBeGreaterThan, 0)
|
2016-03-11 05:39:10 -06:00
|
|
|
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-08 13:57:58 -06:00
|
|
|
})
|
|
|
|
|
2019-09-24 00:54:28 -05:00
|
|
|
Convey("When checking if renderer is backend only plugin", t, func() {
|
|
|
|
pluginScanner := &PluginScanner{}
|
|
|
|
result := pluginScanner.IsBackendOnlyPlugin("renderer")
|
|
|
|
|
|
|
|
So(result, ShouldEqual, true)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("When checking if app is backend only plugin", t, func() {
|
|
|
|
pluginScanner := &PluginScanner{}
|
|
|
|
result := pluginScanner.IsBackendOnlyPlugin("app")
|
|
|
|
|
|
|
|
So(result, ShouldEqual, false)
|
|
|
|
})
|
|
|
|
|
2015-02-27 06:45:00 -06:00
|
|
|
}
|