forked from databricks/terraform-provider-databricks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_job_webhook_test.go
88 lines (85 loc) · 2.22 KB
/
resource_job_webhook_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package jobs
import (
"testing"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/databricks/terraform-provider-databricks/qa"
)
func TestResourceJobUpdate_WebhookNotifications(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "POST",
Resource: "/api/2.1/jobs/reset",
ExpectedRequest: UpdateJobRequest{
JobID: 789,
NewSettings: &JobSettings{
Name: "Webhook test",
Tasks: []JobTaskSettings{
{
TaskKey: "task1",
ExistingClusterID: "abc",
},
},
WebhookNotifications: &jobs.WebhookNotifications{
OnSuccess: []jobs.Webhook{
{Id: "id1"},
},
},
MaxConcurrentRuns: 1,
},
},
Response: Job{
JobID: 789,
},
},
{
Method: "GET",
Resource: "/api/2.1/jobs/get?job_id=789",
Response: Job{
Settings: &JobSettings{
Name: "Webhook test",
Tasks: []JobTaskSettings{
{
TaskKey: "task1",
ExistingClusterID: "abc",
},
},
WebhookNotifications: &jobs.WebhookNotifications{
OnSuccess: []jobs.Webhook{
{Id: "id1"},
},
},
MaxConcurrentRuns: 1,
},
},
},
},
ID: "789",
Update: true,
Resource: ResourceJob(),
InstanceState: map[string]string{
"webhook_notifications.#": "1",
"webhook_notifications.0.on_duration_warning_threshold_exceeded.#": "1",
"webhook_notifications.0.on_duration_warning_threshold_exceeded.0.id": "id1",
"webhook_notifications.0.on_failure.#": "1",
"webhook_notifications.0.on_failure.0.id": "id1",
"webhook_notifications.0.on_start.#": "1",
"webhook_notifications.0.on_start.0.id": "id1",
"webhook_notifications.0.on_success.#": "1",
"webhook_notifications.0.on_success.0.id": "id1",
},
HCL: `
name = "Webhook test"
task {
task_key = "task1"
existing_cluster_id = "abc"
}
webhook_notifications {
// Remove everything but "on_success"
on_success {
id = "id1"
}
}
`,
}.ApplyNoError(t)
}