@@ -17,6 +17,9 @@ import (
17
17
)
18
18
19
19
func TestAccGenerate (t * testing.T ) {
20
+ if testing .Short () {
21
+ t .Skip ("skipping long test" )
22
+ }
20
23
testutils .CheckOSSTestsEnabled (t )
21
24
22
25
cases := []struct {
@@ -29,7 +32,7 @@ func TestAccGenerate(t *testing.T) {
29
32
name : "dashboard" ,
30
33
config : testutils .TestAccExample (t , "resources/grafana_dashboard/resource.tf" ),
31
34
check : func (t * testing.T , tempDir string ) {
32
- assertFiles (t , tempDir , "testdata/generate/dashboard-expected" , " " , []string {
35
+ assertFiles (t , tempDir , "testdata/generate/dashboard" , []string {
33
36
".terraform" ,
34
37
".terraform.lock.hcl" ,
35
38
})
@@ -42,7 +45,7 @@ func TestAccGenerate(t *testing.T) {
42
45
cfg .Format = generate .OutputFormatJSON
43
46
},
44
47
check : func (t * testing.T , tempDir string ) {
45
- assertFiles (t , tempDir , "testdata/generate/dashboard-json" , "" , []string {
48
+ assertFiles (t , tempDir , "testdata/generate/dashboard-json" , []string {
46
49
".terraform" ,
47
50
".terraform.lock.hcl" ,
48
51
})
@@ -55,7 +58,7 @@ func TestAccGenerate(t *testing.T) {
55
58
cfg .IncludeResources = []string {"grafana_dashboard._1_my-dashboard-uid" }
56
59
},
57
60
check : func (t * testing.T , tempDir string ) {
58
- assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , "" , []string {
61
+ assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , []string {
59
62
".terraform" ,
60
63
".terraform.lock.hcl" ,
61
64
})
@@ -68,7 +71,7 @@ func TestAccGenerate(t *testing.T) {
68
71
cfg .IncludeResources = []string {"*._1_my-dashboard-uid" }
69
72
},
70
73
check : func (t * testing.T , tempDir string ) {
71
- assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , "" , []string {
74
+ assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , []string {
72
75
".terraform" ,
73
76
".terraform.lock.hcl" ,
74
77
})
@@ -81,7 +84,7 @@ func TestAccGenerate(t *testing.T) {
81
84
cfg .IncludeResources = []string {"grafana_dashboard.*" }
82
85
},
83
86
check : func (t * testing.T , tempDir string ) {
84
- assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , "" , []string {
87
+ assertFiles (t , tempDir , "testdata/generate/dashboard-filtered" , []string {
85
88
".terraform" ,
86
89
".terraform.lock.hcl" ,
87
90
})
@@ -125,7 +128,12 @@ func TestAccGenerate(t *testing.T) {
125
128
}
126
129
127
130
// assertFiles checks that all files in the "expectedFilesDir" directory match the files in the "gotFilesDir" directory.
128
- func assertFiles (t * testing.T , gotFilesDir , expectedFilesDir , subdir string , ignoreDirEntries []string ) {
131
+ func assertFiles (t * testing.T , gotFilesDir , expectedFilesDir string , ignoreDirEntries []string ) {
132
+ t .Helper ()
133
+ assertFilesSubdir (t , gotFilesDir , expectedFilesDir , "" , ignoreDirEntries )
134
+ }
135
+
136
+ func assertFilesSubdir (t * testing.T , gotFilesDir , expectedFilesDir , subdir string , ignoreDirEntries []string ) {
129
137
t .Helper ()
130
138
131
139
originalGotFilesDir := gotFilesDir
@@ -149,7 +157,7 @@ func assertFiles(t *testing.T, gotFilesDir, expectedFilesDir, subdir string, ign
149
157
}
150
158
151
159
if gotFile .IsDir () {
152
- assertFiles (t , originalGotFilesDir , originalExpectedFilesDir , filepath .Join (subdir , gotFile .Name ()), ignoreDirEntries )
160
+ assertFilesSubdir (t , originalGotFilesDir , originalExpectedFilesDir , filepath .Join (subdir , gotFile .Name ()), ignoreDirEntries )
153
161
continue
154
162
}
155
163
@@ -169,7 +177,7 @@ func assertFiles(t *testing.T, gotFilesDir, expectedFilesDir, subdir string, ign
169
177
}
170
178
for _ , expectedFile := range expectedFiles {
171
179
if expectedFile .IsDir () {
172
- assertFiles (t , originalGotFilesDir , originalExpectedFilesDir , filepath .Join (subdir , expectedFile .Name ()), ignoreDirEntries )
180
+ assertFilesSubdir (t , originalGotFilesDir , originalExpectedFilesDir , filepath .Join (subdir , expectedFile .Name ()), ignoreDirEntries )
173
181
continue
174
182
}
175
183
expectedContent , err := os .ReadFile (filepath .Join (expectedFilesDir , expectedFile .Name ()))
0 commit comments