Skip to content

Commit 7445444

Browse files
committed
change the acceptance test to make the test code to be more idiomatic
1 parent ebd9350 commit 7445444

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

acceptance/acceptance_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ var Ignored = map[string]bool{
8080
}
8181

8282
func TestAccept(t *testing.T) {
83-
testAccept(t, InprocessMode, "")
83+
testAccept(t, InprocessMode, "bundle/deployment/bind/dashboard")
84+
}
85+
86+
func TestAcceptLocal(t *testing.T) {
87+
testAccept(t, InprocessMode, "bundle/deployment/bind/dashboard")
8488
}
8589

8690
func TestInprocessMode(t *testing.T) {

acceptance/bundle/deployment/bind/dashboard/databricks.yml renamed to acceptance/bundle/deployment/bind/dashboard/databricks.yml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bundle:
2-
name: bind-dashboard-test-$BUNDLE_NAME_SUFFIX
2+
name: bind-dashboard-test-$UNIQUE_NAME
33

44
resources:
55
dashboards:

acceptance/bundle/deployment/bind/dashboard/output.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11

2-
=== Bind dashboard test:
3-
=== Substitute variables in the template:
42
=== Create a pre-defined dashboard:
5-
=== Bind dashboard: Updating deployment state...
3+
>>> [CLI] bundle deployment bind dashboard1 [DASHBOARD_ID] --auto-approve
4+
Updating deployment state...
65
Successfully bound databricks_dashboard with an id '[DASHBOARD_ID]'. Run 'bundle deploy' to deploy changes to your workspace
76

8-
=== Deploy bundle: Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UUID]/default/files...
7+
>>> [CLI] bundle deploy
8+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UNIQUE_NAME]/default/files...
99
Deploying resources...
1010
Updating deployment state...
1111
Deployment complete!
1212

13-
=== Read the pre-defined dashboard: {
13+
>>> [CLI] lakeview get [DASHBOARD_ID]
14+
{
1415
"display_name": "test dashboard [UUID]",
1516
"lifecycle_state": "ACTIVE",
1617
"path": "/Users/[USERNAME]/test dashboard [UUID].lvdash.json",
1718
"parent_path": "/Users/[USERNAME]",
1819
"serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Page One\"}]}"
1920
}
2021

21-
=== Unbind the dashboard: Updating deployment state...
22+
>>> [CLI] bundle deployment unbind dashboard1
23+
Updating deployment state...
2224

23-
=== Destroy the bundle: All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UUID]/default
25+
>>> [CLI] bundle destroy --auto-approve
26+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/bind-dashboard-test-[UNIQUE_NAME]/default
2427

2528
Deleting files...
2629
Destroy complete!
2730

28-
=== Read the pre-defined dashboard again (expecting it still exists and is not deleted): {
31+
>>> [CLI] lakeview get [DASHBOARD_ID]
32+
{
2933
"display_name": "test dashboard [UUID]",
3034
"lifecycle_state": "ACTIVE",
3135
"path": "/Users/[USERNAME]/test dashboard [UUID].lvdash.json",
3236
"parent_path": "/Users/[USERNAME]",
3337
"serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Page One\"}]}"
3438
}
35-
36-
=== Test cleanup:
37-
=== Delete the pre-defined dashboard [DASHBOARD_ID]: 0
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
1-
title "Bind dashboard test: "
2-
3-
title "Substitute variables in the template: "
4-
BUNDLE_NAME_SUFFIX=$(uuid)
5-
export BUNDLE_NAME_SUFFIX
6-
71
DASHBOARD_DISPLAY_NAME="test dashboard $(uuid)"
82
if [ -z "$CLOUD_ENV" ]; then
93
DASHBOARD_DISPLAY_NAME="test dashboard 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
104
export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234"
115
fi
126

137
export DASHBOARD_DISPLAY_NAME
14-
envsubst < databricks.yml > out.yml && mv out.yml databricks.yml
8+
envsubst < databricks.yml.tmpl > databricks.yml
159

1610
title "Create a pre-defined dashboard: "
1711
DASHBOARD_ID=$($CLI lakeview create --display-name "${DASHBOARD_DISPLAY_NAME}" --warehouse-id "${TEST_DEFAULT_WAREHOUSE_ID}" --serialized-dashboard '{"pages":[{"name":"02724bf2","displayName":"Untitled page"}]}' | jq -r '.dashboard_id')
1812

1913
cleanupRemoveDashboard() {
20-
title "Test cleanup: "
21-
title "Delete the pre-defined dashboard ${DASHBOARD_ID}: "
2214
$CLI lakeview trash "${DASHBOARD_ID}"
23-
echo $?
2415
}
2516
trap cleanupRemoveDashboard EXIT
2617

27-
title "Bind dashboard: "
28-
$CLI bundle deployment bind dashboard1 "${DASHBOARD_ID}" --auto-approve
18+
trace $CLI bundle deployment bind dashboard1 "${DASHBOARD_ID}" --auto-approve
2919

30-
title "Deploy bundle: "
31-
$CLI bundle deploy
20+
trace $CLI bundle deploy
3221

33-
title "Read the pre-defined dashboard: "
34-
$CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard}'
22+
trace $CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard}'
3523

36-
title "Unbind the dashboard: "
37-
$CLI bundle deployment unbind dashboard1
24+
trace $CLI bundle deployment unbind dashboard1
3825

39-
title "Destroy the bundle: "
40-
$CLI bundle destroy --auto-approve
26+
trace $CLI bundle destroy --auto-approve
4127

42-
title "Read the pre-defined dashboard again (expecting it still exists and is not deleted): "
43-
$CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard}'
28+
# Read the pre-defined dashboard again (expecting it still exists and is not deleted):
29+
trace $CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard}'

acceptance/bundle/deployment/bind/dashboard/test.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Local = true
22
Cloud = true
33
RequiresWarehouse = true
44

5+
Ignore = [
6+
"databricks.yml",
7+
]
8+
59
[[Repls]]
610
Old = "[0-9a-f]{32}"
711
New = "[DASHBOARD_ID]"

0 commit comments

Comments
 (0)