| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2021-03-12 18:51:02 +08:00
										 |  |  | 	"github.com/stretchr/testify/assert" | 
					
						
							|  |  |  | 	"github.com/stretchr/testify/require" | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	symlinkedFolder = "testdata/test-dashboards/symlink" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-01 23:11:25 +08:00
										 |  |  | func TestProvisionedSymlinkedFolder(t *testing.T) { | 
					
						
							| 
									
										
										
										
											2020-04-16 11:46:20 +08:00
										 |  |  | 	cfg := &config{ | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 		Name:    "Default", | 
					
						
							|  |  |  | 		Type:    "file", | 
					
						
							| 
									
										
										
										
											2020-04-16 11:46:20 +08:00
										 |  |  | 		OrgID:   1, | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 		Folder:  "", | 
					
						
							|  |  |  | 		Options: map[string]interface{}{"path": symlinkedFolder}, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-17 23:06:10 +08:00
										 |  |  | 	reader, err := NewDashboardFileReader(cfg, log.New("test-logger"), nil) | 
					
						
							| 
									
										
										
										
											2021-07-21 23:52:41 +08:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		t.Error("expected err to be nil") | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-15 14:12:52 +08:00
										 |  |  | 	want, err := filepath.Abs(containingID) | 
					
						
							| 
									
										
										
										
											2021-03-12 18:51:02 +08:00
										 |  |  | 	require.NoError(t, err) | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-30 19:32:18 +08:00
										 |  |  | 	resolvedPath := reader.resolvedPath() | 
					
						
							| 
									
										
										
										
											2021-03-12 18:51:02 +08:00
										 |  |  | 	assert.Equal(t, want, resolvedPath) | 
					
						
							| 
									
										
										
										
											2018-05-21 15:03:32 +08:00
										 |  |  | } |