Skip to content

Commit b35eedb

Browse files
pieternnfx
authored andcommitted
Add acceptance tests for SQLA resources
1 parent 18e7e10 commit b35eedb

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package acceptance
2+
3+
import (
4+
"testing"
5+
6+
"github.com/databrickslabs/terraform-provider-databricks/internal/acceptance"
7+
)
8+
9+
func TestPreviewAccDashboard(t *testing.T) {
10+
acceptance.Test(t, []acceptance.Step{
11+
{
12+
Template: `
13+
resource "databricks_sql_dashboard" "d1" {
14+
name = "tf-{var.RANDOM}"
15+
16+
// The SQLA API doesn't save tags on create, only on update.
17+
// Uncomment the following when this is fixed.
18+
// tags = [
19+
// "tf-{var.RANDOM}",
20+
// ]
21+
}
22+
23+
resource "databricks_sql_widget" "d1w1" {
24+
dashboard_id = databricks_sql_dashboard.d1.id
25+
text = "hello there!"
26+
27+
position {
28+
size_x = 3
29+
size_y = 4
30+
pos_x = 0
31+
pos_y = 0
32+
}
33+
}
34+
35+
resource "databricks_sql_widget" "d1w2" {
36+
dashboard_id = databricks_sql_dashboard.d1.id
37+
visualization_id = databricks_sql_visualization.q1v1.visualization_id
38+
39+
position {
40+
size_x = 3
41+
size_y = 4
42+
pos_x = 3
43+
pos_y = 0
44+
}
45+
}
46+
47+
resource "databricks_sql_query" "q1" {
48+
data_source_id = databricks_sql_endpoint.this.data_source_id
49+
name = "tf-{var.RANDOM}"
50+
query = "SELECT 1"
51+
}
52+
53+
resource "databricks_sql_visualization" "q1v1" {
54+
query_id = databricks_sql_query.q1.id
55+
type = "table"
56+
name = "My Table"
57+
58+
options = jsonencode({})
59+
}
60+
61+
resource "databricks_sql_endpoint" "this" {
62+
name = "tf-{var.RANDOM}"
63+
cluster_size = "Small"
64+
max_num_clusters = 1
65+
}
66+
`,
67+
},
68+
})
69+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package acceptance
2+
3+
import (
4+
"testing"
5+
6+
"github.com/databrickslabs/terraform-provider-databricks/internal/acceptance"
7+
)
8+
9+
func TestPreviewAccQuery(t *testing.T) {
10+
acceptance.Test(t, []acceptance.Step{
11+
{
12+
Template: `
13+
resource "databricks_sql_query" "q1" {
14+
data_source_id = databricks_sql_endpoint.this.data_source_id
15+
name = "tf-{var.RANDOM}"
16+
query = "SELECT {{ p1 }} AS p1, 2 as p2"
17+
18+
parameter {
19+
name = "p1"
20+
title = "Title for p1"
21+
text {
22+
value = "default"
23+
}
24+
}
25+
26+
tags = [
27+
"t1",
28+
"t2",
29+
]
30+
}
31+
32+
resource "databricks_sql_visualization" "q1v1" {
33+
query_id = databricks_sql_query.q1.id
34+
type = "chart"
35+
name = "My Chart"
36+
description = "Some Description"
37+
38+
options = jsonencode({
39+
columnMapping = {
40+
"p1" = "x"
41+
"p2" = "y"
42+
}
43+
})
44+
}
45+
46+
resource "databricks_sql_endpoint" "this" {
47+
name = "tf-{var.RANDOM}"
48+
cluster_size = "Small"
49+
max_num_clusters = 1
50+
}
51+
`,
52+
},
53+
})
54+
}

0 commit comments

Comments
 (0)