Skip to content

Commit ee001ad

Browse files
Merge pull request #155 from code0-tech/#154-fix-std-control-if
fix std control if
2 parents e749ce4 + b07e1cc commit ee001ad

7 files changed

Lines changed: 451 additions & 19 deletions

File tree

crates/core/src/runtime/functions/control.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ fn r#if(
6262
ctx.push_runtime_trace_label("branch=if".to_string());
6363
run(*if_pointer, ctx)
6464
} else {
65-
Signal::Return(Value {
65+
ctx.push_runtime_trace_label("branch=else".to_string());
66+
Signal::Success(Value {
6667
kind: Some(Kind::NullValue(0)),
6768
})
6869
}

crates/tests/src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,25 @@ impl Testable for Case {
5151
"name": err.name,
5252
"message": err.message,
5353
});
54-
return CaseResult::Failure(input, json);
54+
if json != input.clone().expected_result {
55+
return CaseResult::Failure(input, json);
56+
}
5557
}
5658
taurus_core::context::signal::Signal::Success(value) => {
5759
let json = to_json_value(value);
58-
if json == input.clone().expected_result {
59-
return CaseResult::Success;
60-
} else {
60+
if json != input.clone().expected_result {
6161
return CaseResult::Failure(input, json);
6262
}
6363
}
6464
taurus_core::context::signal::Signal::Return(value) => {
6565
let json = to_json_value(value);
66-
if json == input.clone().expected_result {
67-
return CaseResult::Success;
68-
} else {
66+
if json != input.clone().expected_result {
6967
return CaseResult::Failure(input, json);
7068
}
7169
}
7270
taurus_core::context::signal::Signal::Respond(value) => {
7371
let json = to_json_value(value);
74-
if json == input.clone().expected_result {
75-
return CaseResult::Success;
76-
} else {
72+
if json != input.clone().expected_result {
7773
return CaseResult::Failure(input, json);
7874
}
7975
}

flows/01_return_object.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"input": null,
77
"expected_result": {
8-
"status_code": 200,
8+
"http_status_code": 200,
99
"headers": {
1010
"Header": "X"
1111
},

flows/02_return_flow_input.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"input": null,
77
"expected_result": {
8-
"status_code": 200,
8+
"http_status_code": 200,
99
"headers": {
1010
"Authentication": "X"
1111
},
@@ -23,7 +23,7 @@
2323
]
2424
},
2525
"expected_result": {
26-
"status_code": 200,
26+
"http_status_code": 200,
2727
"headers": {
2828
"Authentication": "X"
2929
},

flows/04_example_action.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
{
66
"input": null,
77
"expected_result": {
8-
"status_code": 200,
9-
"headers": {
10-
"Header": "X"
11-
},
12-
"payload": "Hello World"
8+
"message": "Remote runtime not configured",
9+
"name": "RemoteRuntimeNotConfigured"
1310
}
1411
}
1512
],

flows/05_if_control.json

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{
2+
"name": "05_if_control",
3+
"description": "This flow expects an object as input (from http request) structured payload.test = bool which the flow will return",
4+
"inputs": [
5+
{
6+
"input": {
7+
"http_method": "GET",
8+
"headers": {
9+
"Content-Type": "text/plain"
10+
},
11+
"payload": {
12+
"test": 1
13+
}
14+
},
15+
"expected_result": {
16+
"message": "Expected a bool value but received [Eval(Value { kind: Some(NumberValue(NumberValue { number: Some(Integer(1)) })) }), Thunk(12)]",
17+
"name": "InvalidArgumentRuntimeError"
18+
}
19+
},
20+
{
21+
"input": {
22+
"http_method": "GET",
23+
"headers": {
24+
"Content-Type": "text/plain"
25+
},
26+
"payload": {
27+
"test": false
28+
}
29+
},
30+
"expected_result": {
31+
"http_status_code": 200,
32+
"headers": {},
33+
"payload": "Blub"
34+
}
35+
},
36+
{
37+
"input": {
38+
"http_method": "GET",
39+
"headers": {
40+
"Content-Type": "text/plain"
41+
},
42+
"payload": {
43+
"test": true
44+
}
45+
},
46+
"expected_result": {
47+
"http_status_code": 200,
48+
"headers": {},
49+
"payload": true
50+
}
51+
}
52+
],
53+
"flow": {
54+
"flowId": "2",
55+
"projectId": "1",
56+
"type": "REST",
57+
"settings": [
58+
{
59+
"databaseId": "3",
60+
"flowSettingId": "httpURL",
61+
"value": {
62+
"stringValue": "/test2"
63+
}
64+
},
65+
{
66+
"databaseId": "4",
67+
"flowSettingId": "httpMethod",
68+
"value": {
69+
"stringValue": "GET"
70+
}
71+
}
72+
],
73+
"startingNodeId": "11",
74+
"nodeFunctions": [
75+
{
76+
"databaseId": "13",
77+
"runtimeFunctionId": "rest::control::respond",
78+
"parameters": [
79+
{
80+
"databaseId": "57",
81+
"runtimeParameterId": "http_response",
82+
"value": {
83+
"referenceValue": {
84+
"nodeId": "14"
85+
}
86+
}
87+
}
88+
]
89+
},
90+
{
91+
"databaseId": "14",
92+
"runtimeFunctionId": "http::response::create",
93+
"parameters": [
94+
{
95+
"databaseId": "54",
96+
"runtimeParameterId": "http_status_code",
97+
"value": {
98+
"literalValue": {
99+
"numberValue": {
100+
"integer": "200"
101+
}
102+
}
103+
}
104+
},
105+
{
106+
"databaseId": "55",
107+
"runtimeParameterId": "headers",
108+
"value": {
109+
"literalValue": {
110+
"structValue": {}
111+
}
112+
}
113+
},
114+
{
115+
"databaseId": "56",
116+
"runtimeParameterId": "payload",
117+
"value": {
118+
"literalValue": {
119+
"stringValue": "Blub"
120+
}
121+
}
122+
}
123+
],
124+
"nextNodeId": "13"
125+
},
126+
{
127+
"databaseId": "11",
128+
"runtimeFunctionId": "std::control::if",
129+
"parameters": [
130+
{
131+
"databaseId": "49",
132+
"runtimeParameterId": "condition",
133+
"value": {
134+
"referenceValue": {
135+
"paths": [
136+
{
137+
"path": "payload"
138+
},
139+
{
140+
"path": "test"
141+
}
142+
],
143+
"flowInput": {}
144+
}
145+
}
146+
},
147+
{
148+
"databaseId": "50",
149+
"runtimeParameterId": "runnable",
150+
"value": {
151+
"nodeFunctionId": "12"
152+
}
153+
}
154+
],
155+
"nextNodeId": "14"
156+
},
157+
{
158+
"databaseId": "15",
159+
"runtimeFunctionId": "rest::control::respond",
160+
"parameters": [
161+
{
162+
"databaseId": "58",
163+
"runtimeParameterId": "http_response",
164+
"value": {
165+
"referenceValue": {
166+
"nodeId": "12"
167+
}
168+
}
169+
}
170+
]
171+
},
172+
{
173+
"databaseId": "12",
174+
"runtimeFunctionId": "http::response::create",
175+
"parameters": [
176+
{
177+
"databaseId": "51",
178+
"runtimeParameterId": "http_status_code",
179+
"value": {
180+
"literalValue": {
181+
"numberValue": {
182+
"integer": "200"
183+
}
184+
}
185+
}
186+
},
187+
{
188+
"databaseId": "52",
189+
"runtimeParameterId": "headers",
190+
"value": {
191+
"literalValue": {
192+
"structValue": {}
193+
}
194+
}
195+
},
196+
{
197+
"databaseId": "53",
198+
"runtimeParameterId": "payload",
199+
"value": {
200+
"referenceValue": {
201+
"paths": [
202+
{
203+
"path": "payload"
204+
},
205+
{
206+
"path": "test"
207+
}
208+
],
209+
"flowInput": {}
210+
}
211+
}
212+
}
213+
],
214+
"nextNodeId": "15"
215+
}
216+
],
217+
"projectSlug": "codezero-project",
218+
"signature": "(httpURL: HTTP_URL, httpMethod: HTTP_METHOD): { payload: { test: BOOLEAN }, headers: { test: TEXT } }"
219+
}
220+
}

0 commit comments

Comments
 (0)