| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | // +build linux
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package dashboards | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"path/filepath" | 
					
						
							|  |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-13 14:45:54 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/infra/log" | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	symlinkedFolder = "testdata/test-dashboards/symlink" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func TestProvsionedSymlinkedFolder(t *testing.T) { | 
					
						
							|  |  |  | 	cfg := &DashboardsAsConfig{ | 
					
						
							|  |  |  | 		Name:    "Default", | 
					
						
							|  |  |  | 		Type:    "file", | 
					
						
							|  |  |  | 		OrgId:   1, | 
					
						
							|  |  |  | 		Folder:  "", | 
					
						
							|  |  |  | 		Options: map[string]interface{}{"path": symlinkedFolder}, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	reader, err := NewDashboardFileReader(cfg, log.New("test-logger")) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		t.Error("expected err to be nil") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	want, err := filepath.Abs(containingId) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2018-09-20 19:20:43 +08:00
										 |  |  | 		t.Errorf("expected err to be nil") | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-30 19:32:18 +08:00
										 |  |  | 	resolvedPath := reader.resolvedPath() | 
					
						
							| 
									
										
										
										
											2018-09-20 19:20:43 +08:00
										 |  |  | 	if resolvedPath != want { | 
					
						
							|  |  |  | 		t.Errorf("got %s want %s", resolvedPath, want) | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |