Skip to content

Commit 43d0fb2

Browse files
docs: update examples
1 parent bb4f510 commit 43d0fb2

21 files changed

+424
-412
lines changed

ctk/features/branch.feature

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: Branch Task
2+
As an implementer of the workflow DSL
3+
I want to ensure that branch tasks can be executed within the workflow
4+
So that my implementation conforms to the expected behavior
5+
6+
# Tests branch tasks With competing concurrent sub tasks
7+
Scenario: Branch Task With Competing Concurrent Sub Tasks
8+
Given a workflow with definition:
9+
"""yaml
10+
document:
11+
dsl: 1.0.0-alpha1
12+
namespace: default
13+
name: branch-task-with-compete
14+
do:
15+
- branchWithCompete:
16+
branch:
17+
compete: true
18+
on:
19+
- setRed:
20+
set:
21+
colors: ${ .colors + ["red"] }
22+
- setGreen:
23+
set:
24+
colors: ${ .colors + ["green"] }
25+
- setBlue:
26+
set:
27+
colors: ${ .colors + ["blue"] }
28+
"""
29+
When the workflow is executed
30+
Then the workflow should complete
31+
And the workflow output should have a 'colors' property containing 1 items

ctk/features/call.feature

+44-39
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Feature: Call Task
1515
namespace: default
1616
name: http-call-with-content-output
1717
do:
18-
call: http
19-
with:
20-
method: get
21-
endpoint:
22-
uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status}
23-
output:
24-
from: .[0]
18+
- findPet:
19+
call: http
20+
with:
21+
method: get
22+
endpoint:
23+
uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status}
24+
output:
25+
from: .[0]
2526
"""
2627
And given the workflow input is:
2728
"""yaml
@@ -42,12 +43,13 @@ Feature: Call Task
4243
namespace: default
4344
name: http-call-with-response-output
4445
do:
45-
call: http
46-
with:
47-
method: get
48-
endpoint:
49-
uri: https://petstore.swagger.io/v2/pet/{petId}
50-
output: response
46+
- getPet:
47+
call: http
48+
with:
49+
method: get
50+
endpoint:
51+
uri: https://petstore.swagger.io/v2/pet/{petId}
52+
output: response
5153
"""
5254
And given the workflow input is:
5355
"""yaml
@@ -68,15 +70,16 @@ Feature: Call Task
6870
namespace: default
6971
name: http-call-with-basic-auth
7072
do:
71-
call: http
72-
with:
73-
method: get
74-
endpoint:
75-
uri: https://httpbin.org/basic-auth/{username}/{password}
76-
authentication:
77-
basic:
78-
username: ${ .username }
79-
password: ${ .password }
73+
- login:
74+
call: http
75+
with:
76+
method: get
77+
endpoint:
78+
uri: https://httpbin.org/basic-auth/{username}/{password}
79+
authentication:
80+
basic:
81+
username: ${ .username }
82+
password: ${ .password }
8083
"""
8184
And given the workflow input is:
8285
"""yaml
@@ -96,15 +99,16 @@ Feature: Call Task
9699
namespace: default
97100
name: openapi-call-with-content-output
98101
do:
99-
call: openapi
100-
with:
101-
document:
102-
uri: https://petstore.swagger.io/v2/swagger.json
103-
operation: findPetsByStatus
104-
parameters:
105-
status: ${ .status }
106-
output:
107-
from: . | length
102+
- findPet:
103+
call: openapi
104+
with:
105+
document:
106+
uri: "https://petstore.swagger.io/v2/swagger.json"
107+
operation: findPetsByStatus
108+
parameters:
109+
status: ${ .status }
110+
output:
111+
from: . | length
108112
"""
109113
And given the workflow input is:
110114
"""yaml
@@ -123,14 +127,15 @@ Feature: Call Task
123127
namespace: default
124128
name: openapi-call-with-response-output
125129
do:
126-
call: openapi
127-
with:
128-
document:
129-
uri: https://petstore.swagger.io/v2/swagger.json
130-
operation: getPetById
131-
parameters:
132-
petId: ${ .petId }
133-
output: response
130+
- getPet:
131+
call: openapi
132+
with:
133+
document:
134+
uri: "https://petstore.swagger.io/v2/swagger.json"
135+
operation: getPetById
136+
parameters:
137+
petId: ${ .petId }
138+
output: response
134139
"""
135140
And given the workflow input is:
136141
"""yaml

ctk/features/composite.feature

-57
This file was deleted.

ctk/features/data-flow.feature

+30-30
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ Feature: Data Flow
1212
namespace: default
1313
name: output-filtering
1414
do:
15-
input:
16-
from: .user.claims.subject #filters the input of the task, using only the user's subject
17-
set:
18-
playerId: ${ . }
15+
- setPlayerId:
16+
input:
17+
from: .user.claims.subject #filters the input of the task, using only the user's subject
18+
set:
19+
playerId: ${ . }
1920
"""
2021
And given the workflow input is:
2122
"""yaml
@@ -38,13 +39,14 @@ Feature: Data Flow
3839
namespace: default
3940
name: output-filtering
4041
do:
41-
call: http
42-
with:
43-
method: get
44-
endpoint:
45-
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
46-
output:
47-
from: .id #filters the output of the http call, using only the id of the returned object
42+
- getPet:
43+
call: http
44+
with:
45+
method: get
46+
endpoint:
47+
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
48+
output:
49+
from: .id #filters the output of the http call, using only the id of the returned object
4850
"""
4951
And given the workflow input is:
5052
"""yaml
@@ -64,25 +66,23 @@ Feature: Data Flow
6466
dsl: 1.0.0-alpha1
6567
namespace: default
6668
name: non-object-output
67-
do:
68-
execute:
69-
sequentially:
70-
- getPetById1:
71-
call: http
72-
with:
73-
method: get
74-
endpoint:
75-
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
76-
output:
77-
from: .id
78-
- getPetById2:
79-
call: http
80-
with:
81-
method: get
82-
endpoint:
83-
uri: https://petstore.swagger.io/v2/pet/2
84-
output:
85-
from: '{ ids: [ $input, .id ] }'
69+
do:+
70+
- getPetById1:
71+
call: http
72+
with:
73+
method: get
74+
endpoint:
75+
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
76+
output:
77+
from: .id
78+
- getPetById2:
79+
call: http
80+
with:
81+
method: get
82+
endpoint:
83+
uri: https://petstore.swagger.io/v2/pet/2
84+
output:
85+
from: '{ ids: [ $input, .id ] }'
8686
"""
8787
When the workflow is executed
8888
Then the workflow should complete with output:

ctk/features/do.feature

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Feature: Do Task
2+
As an implementer of the workflow DSL
3+
I want to ensure that composite tasks can be executed within the workflow
4+
So that my implementation conforms to the expected behavior
5+
6+
# Tests composite tasks with sequential sub tasks
7+
Scenario: Do Task With Sequential Sub Tasks
8+
Given a workflow with definition:
9+
"""yaml
10+
document:
11+
dsl: 1.0.0-alpha1
12+
namespace: default
13+
name: composite-sequential
14+
do:
15+
- setRed:
16+
set:
17+
colors: ${ .colors + ["red"] }
18+
- setGreen:
19+
do:
20+
- set:
21+
colors: ${ .colors + ["green"] }
22+
- setBlue:
23+
set:
24+
colors: ${ .colors + ["blue"] }
25+
"""
26+
When the workflow is executed
27+
Then the workflow should complete with output:
28+
"""yaml
29+
colors: [ red, green, blue ]
30+
"""

ctk/features/emit.feature

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ Feature: Emit Task
1212
namespace: default
1313
name: emit
1414
do:
15-
emit:
16-
event:
17-
with:
18-
source: https://fake-source.com
19-
type: com.fake-source.user.greeted.v1
20-
data:
21-
greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" }
15+
- emitEvent:
16+
emit:
17+
event:
18+
with:
19+
source: https://fake-source.com
20+
type: com.fake-source.user.greeted.v1
21+
data:
22+
greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" }
2223
"""
2324
And given the workflow input is:
2425
"""yaml

0 commit comments

Comments
 (0)