-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_early_test.go
More file actions
37 lines (32 loc) · 1.03 KB
/
Copy pathcomplete_early_test.go
File metadata and controls
37 lines (32 loc) · 1.03 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
package catbird
import (
"context"
"errors"
"testing"
)
func TestCompleteEarlyCreatesTypedControlError(t *testing.T) {
err := CompleteEarly(withFlowRunScope(context.Background(), nil, "my_flow", 42, nil), map[string]any{"ok": true}, "fast-path")
if err == nil {
t.Fatal("expected control error")
}
completion, ok := asEarlyCompletion(err)
if !ok {
t.Fatalf("expected early completion error type, got %T", err)
}
if completion.reason != "fast-path" {
t.Fatalf("unexpected reason: %q", completion.reason)
}
if completion.flowName != "my_flow" || completion.flowRunID != 42 {
t.Fatalf("unexpected run scope: %s/%d", completion.flowName, completion.flowRunID)
}
outputMap, ok := completion.output.(map[string]any)
if !ok || outputMap["ok"] != true {
t.Fatalf("unexpected output body: %#v", completion.output)
}
}
func TestCompleteEarlyRequiresFlowContext(t *testing.T) {
err := CompleteEarly(context.Background(), "out", "reason")
if !errors.Is(err, ErrNoRunContext) {
t.Fatalf("expected ErrNoRunContext, got %v", err)
}
}