-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvisualiser_test.go
33 lines (25 loc) · 967 Bytes
/
visualiser_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
package workflow_test
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/luno/workflow"
)
func TestCreateDiagram(t *testing.T) {
b := workflow.NewBuilder[string, status]("example")
b.AddStep(StatusStart, func(ctx context.Context, r *workflow.Run[string, status]) (status, error) {
return StatusMiddle, nil
}, StatusMiddle, StatusEnd)
b.AddStep(StatusMiddle, func(ctx context.Context, r *workflow.Run[string, status]) (status, error) {
return StatusEnd, nil
}, StatusEnd,
)
wf := b.Build(nil, nil, nil)
err := workflow.CreateDiagram(wf, "./testdata/graph-visualisation.md", workflow.LeftToRightDirection)
require.Nil(t, err)
}
func TestCreateDiagramValidation(t *testing.T) {
w := (workflow.API[string, status])(nil)
err := workflow.CreateDiagram(w, "./testdata/should-not-exist.md", workflow.LeftToRightDirection)
require.Equal(t, err.Error(), "cannot create diagram for non-original workflow.Workflow type")
}