Skip to content

Commit 9420f2a

Browse files
Config Generation: Add test for JSON
1 parent d58abb4 commit 9420f2a

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

Diff for: pkg/generate/generate_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ func TestAccGenerate(t *testing.T) {
3535
})
3636
},
3737
},
38+
{
39+
name: "dashboard-json",
40+
config: testutils.TestAccExample(t, "resources/grafana_dashboard/resource.tf"),
41+
generateConfig: func(cfg *generate.Config) {
42+
cfg.Format = generate.OutputFormatJSON
43+
},
44+
check: func(t *testing.T, tempDir string) {
45+
assertFiles(t, tempDir, "testdata/generate/dashboard-json", "", []string{
46+
".terraform",
47+
".terraform.lock.hcl",
48+
})
49+
},
50+
},
3851
{
3952
name: "dashboard-filter-strict",
4053
config: testutils.TestAccExample(t, "resources/grafana_dashboard/resource.tf"),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"import": [
3+
{
4+
"id": "1:my-dashboard-uid",
5+
"to": "grafana_dashboard._1_my-dashboard-uid"
6+
},
7+
{
8+
"id": "1:my-folder-uid",
9+
"to": "grafana_folder._1_my-folder-uid"
10+
},
11+
{
12+
"id": "1:policy",
13+
"to": "grafana_notification_policy._1_policy"
14+
},
15+
{
16+
"id": "1",
17+
"to": "grafana_organization_preferences._1"
18+
}
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"provider": {
3+
"grafana": [
4+
{
5+
"auth": "admin:admin",
6+
"url": "http://localhost:3000"
7+
}
8+
]
9+
},
10+
"terraform": [
11+
{
12+
"required_providers": [
13+
{
14+
"grafana": {
15+
"source": "grafana/grafana",
16+
"version": "3.0.0"
17+
}
18+
}
19+
]
20+
}
21+
]
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"resource": {
3+
"grafana_dashboard": {
4+
"_1_my-dashboard-uid": [
5+
{
6+
"config_json": "${jsonencode({\n title = \"My Dashboard\"\n uid = \"my-dashboard-uid\"\n })}",
7+
"folder": "my-folder-uid"
8+
}
9+
]
10+
},
11+
"grafana_folder": {
12+
"_1_my-folder-uid": [
13+
{
14+
"title": "My Folder",
15+
"uid": "my-folder-uid"
16+
}
17+
]
18+
},
19+
"grafana_notification_policy": {
20+
"_1_policy": [
21+
{
22+
"contact_point": "grafana-default-email",
23+
"disable_provenance": true,
24+
"group_by": [
25+
"grafana_folder",
26+
"alertname"
27+
]
28+
}
29+
]
30+
},
31+
"grafana_organization_preferences": {
32+
"_1": [
33+
{}
34+
]
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)