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