forked from deepnoodle-ai/workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow_test.go
More file actions
74 lines (65 loc) · 1.6 KB
/
Copy pathworkflow_test.go
File metadata and controls
74 lines (65 loc) · 1.6 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package workflow
import (
"testing"
"github.com/deepnoodle-ai/workflow/internal/require"
)
func TestWorkflowStepNames(t *testing.T) {
wf, err := New(Options{
Name: "test-workflow",
Steps: []*Step{
{Name: "step1"},
{Name: "step2"},
},
})
require.NoError(t, err)
require.Equal(t, []string{"step1", "step2"}, wf.StepNames())
steps := wf.Steps()
require.Len(t, steps, 2)
require.Equal(t, "step1", steps[0].Name)
require.Equal(t, "step2", steps[1].Name)
}
func TestWorkflowDescription(t *testing.T) {
t.Run("with description", func(t *testing.T) {
wf, err := New(Options{
Name: "test-workflow",
Description: "A test workflow",
Steps: []*Step{
{Name: "step1"},
},
})
require.NoError(t, err)
require.Equal(t, "A test workflow", wf.Description())
})
t.Run("without description", func(t *testing.T) {
wf, err := New(Options{
Name: "test-workflow",
Steps: []*Step{
{Name: "step1"},
},
})
require.NoError(t, err)
require.Equal(t, "", wf.Description())
})
}
func TestInvalidWorkflows(t *testing.T) {
t.Run("empty workflow", func(t *testing.T) {
_, err := New(Options{})
require.Error(t, err)
require.Contains(t, err.Error(), "workflow: name required")
})
t.Run("no steps", func(t *testing.T) {
_, err := New(Options{
Name: "test-workflow",
})
require.Error(t, err)
require.Contains(t, err.Error(), "steps required")
})
t.Run("empty step name", func(t *testing.T) {
_, err := New(Options{
Name: "test-workflow",
Steps: []*Step{{Name: ""}},
})
require.Error(t, err)
require.Contains(t, err.Error(), "empty step name")
})
}