| 
									
										
										
										
											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) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Convey("When scaning for plugins", t, func() { | 
					
						
							| 
									
										
										
										
											2015-11-27 17:17:27 +08:00
										 |  |  | 		setting.StaticRootPath, _ = filepath.Abs("../../public/") | 
					
						
							|  |  |  | 		setting.Cfg = ini.Empty() | 
					
						
							| 
									
										
										
										
											2015-11-27 17:04:43 +08:00
										 |  |  | 		err := 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) | 
					
						
							| 
									
										
										
										
											2016-01-10 06:34:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		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.app-test") | 
					
						
							|  |  |  | 		sec.NewKey("path", "../../tests/app-plugin-json") | 
					
						
							|  |  |  | 		err := Init() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		So(err, ShouldBeNil) | 
					
						
							|  |  |  | 		So(len(Apps), ShouldBeGreaterThan, 0) | 
					
						
							| 
									
										
										
										
											2016-01-09 15:12:27 +08:00
										 |  |  | 		So(Apps["app-example"].Info.Logos.Large, ShouldEqual, "public/plugins/app-example/img/logo_large.png") | 
					
						
							| 
									
										
										
										
											2016-01-09 03:57:58 +08:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-27 20:45:00 +08:00
										 |  |  | } |