-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow_update_test.go
More file actions
60 lines (52 loc) · 2.04 KB
/
workflow_update_test.go
File metadata and controls
60 lines (52 loc) · 2.04 KB
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
package unstructured
import (
"errors"
"net/http"
"strconv"
"testing"
"time"
)
func TestUpdateWorkflow(t *testing.T) {
t.Parallel()
client, mux := testclient(t)
id := "16b80fee-64dc-472d-8f26-1d7729b6423d"
mux.UpdateWorkflow = func(w http.ResponseWriter, _ *http.Request) {
response := []byte(`{` +
` "id": "` + id + `",` +
` "name": "test_workflow",` +
` "status": "active",` +
` "workflow_type": "advanced",` +
` "created_at": "2025-06-22T11:37:21.648Z",` +
` "sources": ["f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c"],` +
` "destinations": ["aeebecc7-9d8e-4625-bf1d-815c2f084869"],` +
` "schedule": {"crontab_entries": [{"cron_expression": "0 0 * * 0"}]},` +
` "workflow_nodes": []` +
`}`)
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Length", strconv.Itoa(len(response)))
w.Write(response)
}
updated, err := client.UpdateWorkflow(testContext(t), UpdateWorkflowRequest{
ID: id,
Name: String("test_workflow"),
WorkflowType: Ptr(WorkflowTypeAdvanced),
Schedule: String("weekly"),
SourceID: String("f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c"),
DestinationID: String("aeebecc7-9d8e-4625-bf1d-815c2f084869"),
})
if err != nil {
t.Fatalf("failed to update workflow: %v", err)
}
if err := errors.Join(
eq("updated_workflow.id", updated.ID, id),
eq("updated_workflow.name", updated.Name, "test_workflow"),
eq("updated_workflow.status", updated.Status, WorkflowStateActive),
eq("updated_workflow.workflow_type", ToVal(updated.WorkflowType), WorkflowTypeAdvanced),
equal("workflow.created_at", updated.CreatedAt, time.Date(2025, 6, 22, 11, 37, 21, 648000000, time.UTC)),
eqs("updated_workflow.sources", updated.Sources, []string{"f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c"}),
eqs("updated_workflow.destinations", updated.Destinations, []string{"aeebecc7-9d8e-4625-bf1d-815c2f084869"}),
eqs("updated_workflow.schedule.crontab_entries", updated.Schedule.CronTabEntries, []CronTabEntry{{CronExpression: "0 0 * * 0"}}),
); err != nil {
t.Error(err)
}
}