Skip to content

Commit 603b40d

Browse files
committed
feat: adjusted test suite paramter order for new signature of rest control respond
1 parent 0e71acf commit 603b40d

12 files changed

Lines changed: 189 additions & 175 deletions

crates/taurus-core/src/runtime/engine.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,9 @@ mod tests {
11941194
"rest::control::respond",
11951195
vec![
11961196
literal_param(100, "http_status_code", int_value(200)),
1197-
literal_param(101, "headers", empty_struct_value()),
11981197
literal_param(102, "http_schema", string_value("application/json")),
11991198
literal_param(103, "payload", string_value("hello")),
1199+
literal_param(101, "headers", empty_struct_value()),
12001200
],
12011201
None,
12021202
);
@@ -1212,15 +1212,15 @@ mod tests {
12121212
assert_eq!(node_result.parameter_results[0].value, Some(int_value(200)));
12131213
assert_eq!(
12141214
node_result.parameter_results[1].value,
1215-
Some(empty_struct_value())
1215+
Some(string_value("application/json"))
12161216
);
12171217
assert_eq!(
12181218
node_result.parameter_results[2].value,
1219-
Some(string_value("application/json"))
1219+
Some(string_value("hello"))
12201220
);
12211221
assert_eq!(
12221222
node_result.parameter_results[3].value,
1223-
Some(string_value("hello"))
1223+
Some(empty_struct_value())
12241224
);
12251225
assert!(matches!(
12261226
node_result.result,
@@ -1438,9 +1438,9 @@ mod tests {
14381438
"rest::control::respond",
14391439
vec![
14401440
literal_param(1, "http_status_code", int_value(200)),
1441-
literal_param(2, "headers", empty_struct_value()),
14421441
literal_param(3, "http_schema", string_value("text/plain")),
14431442
literal_param(4, "payload", string_value("20")),
1443+
literal_param(2, "headers", empty_struct_value()),
14441444
],
14451445
None,
14461446
);
@@ -1480,6 +1480,7 @@ mod tests {
14801480
fields.insert("http_status_code".to_string(), int_value(200));
14811481
fields.insert("headers".to_string(), empty_struct_value());
14821482
fields.insert("payload".to_string(), string_value("20"));
1483+
fields.insert("http_schema".to_string(), string_value("text/plain"));
14831484
Value {
14841485
kind: Some(Kind::StructValue(Struct { fields })),
14851486
}
@@ -1581,9 +1582,9 @@ mod tests {
15811582
"rest::control::respond",
15821583
vec![
15831584
literal_param(100, "http_status_code", int_value(200)),
1584-
literal_param(101, "headers", empty_struct_value()),
15851585
literal_param(102, "http_schema", string_value("application/json")),
15861586
literal_param(103, "payload", string_value("hello")),
1587+
literal_param(101, "headers", empty_struct_value()),
15871588
],
15881589
Some(2),
15891590
);

crates/taurus-core/src/runtime/functions/http.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,20 @@ fn respond(
3434
_run: &mut crate::handler::registry::ThunkRunner<'_>,
3535
) -> Signal {
3636
args!(args => http_status_code: i64, http_schema: String, payload: Value, headers: Value);
37-
37+
3838
let http_headers = match headers_from_value(&headers) {
3939
Ok(headers) => headers,
4040
Err(signal) => return signal,
4141
};
4242

4343
let mut fields = HashMap::new();
4444
fields.insert("http_status_code".to_string(), http_status_code.to_value());
45-
fields.insert("headers".to_string(), Value {
46-
kind: Some(Kind::StructValue(http_headers))
47-
});
45+
fields.insert(
46+
"headers".to_string(),
47+
Value {
48+
kind: Some(Kind::StructValue(http_headers)),
49+
},
50+
);
4851

4952
fields.insert("payload".to_string(), payload);
5053
fields.insert("http_schema".to_string(), http_schema.to_value());

crates/taurus/src/app/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ pub async fn run() {
2828
let client = connect_nats(&config).await;
2929

3030
let mut health_task = spawn_health_task(&config);
31-
let (
32-
runtime_status_service,
33-
runtime_execution_service,
34-
mut runtime_status_heartbeat_task,
35-
) = setup_dynamic_services_if_needed(&config).await;
31+
let (runtime_status_service, runtime_execution_service, mut runtime_status_heartbeat_task) =
32+
setup_dynamic_services_if_needed(&config).await;
3633

3734
let nats_remote = NATSRemoteRuntime::new(client.clone());
3835
let runtime_emitter = NATSRespondEmitter::new(client.clone());

crates/taurus/src/app/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async fn execute_flow(
176176
input,
177177
signal: report.signal,
178178
node_execution_results: report.node_execution_results,
179-
}
179+
}
180180
}
181181

182182
fn parse_execution_id_from_subject(

flows/01_return_object.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"headers": {
1010
"Header": "X"
1111
},
12-
"payload": "Hello World"
12+
"payload": "Hello World",
13+
"http_schema": "application/json"
1314
}
1415
}
1516
],
@@ -32,21 +33,6 @@
3233
}
3334
}
3435
},
35-
{
36-
"databaseId": "2",
37-
"runtimeParameterId": "headers",
38-
"value": {
39-
"literalValue": {
40-
"structValue": {
41-
"fields": {
42-
"Header": {
43-
"stringValue": "X"
44-
}
45-
}
46-
}
47-
}
48-
}
49-
},
5036
{
5137
"databaseId": "4",
5238
"runtimeParameterId": "http_schema",
@@ -64,6 +50,21 @@
6450
"stringValue": "Hello World"
6551
}
6652
}
53+
},
54+
{
55+
"databaseId": "2",
56+
"runtimeParameterId": "headers",
57+
"value": {
58+
"literalValue": {
59+
"structValue": {
60+
"fields": {
61+
"Header": {
62+
"stringValue": "X"
63+
}
64+
}
65+
}
66+
}
67+
}
6768
}
6869
]
6970
}

flows/02_return_flow_input.json

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"headers": {
1010
"Authentication": "X"
1111
},
12-
"payload": null
12+
"payload": null,
13+
"http_schema": "application/json"
1314
}
1415
},
1516
{
@@ -35,7 +36,8 @@
3536
"cat",
3637
"bird"
3738
]
38-
}
39+
},
40+
"http_schema": "application/json"
3941
}
4042
}
4143
],
@@ -60,21 +62,6 @@
6062
}
6163
}
6264
},
63-
{
64-
"databaseId": "6",
65-
"runtimeParameterId": "headers",
66-
"value": {
67-
"literalValue": {
68-
"structValue": {
69-
"fields": {
70-
"Authentication": {
71-
"stringValue": "X"
72-
}
73-
}
74-
}
75-
}
76-
}
77-
},
7865
{
7966
"databaseId": "8",
8067
"runtimeParameterId": "http_schema",
@@ -92,6 +79,21 @@
9279
"flowInput": {}
9380
}
9481
}
82+
},
83+
{
84+
"databaseId": "6",
85+
"runtimeParameterId": "headers",
86+
"value": {
87+
"literalValue": {
88+
"structValue": {
89+
"fields": {
90+
"Authentication": {
91+
"stringValue": "X"
92+
}
93+
}
94+
}
95+
}
96+
}
9597
}
9698
]
9799
}

flows/05_if_control.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"expected_result": {
3131
"http_status_code": 200,
3232
"headers": {},
33-
"payload": "Blub"
33+
"payload": "Blub",
34+
"http_schema": "application/json"
3435
}
3536
},
3637
{
@@ -46,7 +47,8 @@
4647
"expected_result": {
4748
"http_status_code": 200,
4849
"headers": {},
49-
"payload": "Blub"
50+
"payload": "Blub",
51+
"http_schema": "application/json"
5052
}
5153
}
5254
],
@@ -87,15 +89,6 @@
8789
}
8890
}
8991
},
90-
{
91-
"databaseId": "55",
92-
"runtimeParameterId": "headers",
93-
"value": {
94-
"literalValue": {
95-
"structValue": {}
96-
}
97-
}
98-
},
9992
{
10093
"databaseId": "57",
10194
"runtimeParameterId": "http_schema",
@@ -113,6 +106,15 @@
113106
"stringValue": "Blub"
114107
}
115108
}
109+
},
110+
{
111+
"databaseId": "55",
112+
"runtimeParameterId": "headers",
113+
"value": {
114+
"literalValue": {
115+
"structValue": {}
116+
}
117+
}
116118
}
117119
]
118120
},
@@ -166,15 +168,6 @@
166168
}
167169
}
168170
},
169-
{
170-
"databaseId": "52",
171-
"runtimeParameterId": "headers",
172-
"value": {
173-
"literalValue": {
174-
"structValue": {}
175-
}
176-
}
177-
},
178171
{
179172
"databaseId": "54",
180173
"runtimeParameterId": "http_schema",
@@ -200,6 +193,15 @@
200193
"flowInput": {}
201194
}
202195
}
196+
},
197+
{
198+
"databaseId": "52",
199+
"runtimeParameterId": "headers",
200+
"value": {
201+
"literalValue": {
202+
"structValue": {}
203+
}
204+
}
203205
}
204206
]
205207
}

flows/06_if_else_control.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"expected_result": {
3131
"http_status_code": 200,
3232
"headers": {},
33-
"payload": "Blub"
33+
"payload": "Blub",
34+
"http_schema": "application/json"
3435
}
3536
},
3637
{
@@ -46,7 +47,8 @@
4647
"expected_result": {
4748
"http_status_code": 200,
4849
"headers": {},
49-
"payload": "Blob"
50+
"payload": "Blob",
51+
"http_schema": "application/json"
5052
}
5153
}
5254
],
@@ -87,15 +89,6 @@
8789
}
8890
}
8991
},
90-
{
91-
"databaseId": "78",
92-
"runtimeParameterId": "headers",
93-
"value": {
94-
"literalValue": {
95-
"structValue": {}
96-
}
97-
}
98-
},
9992
{
10093
"databaseId": "80",
10194
"runtimeParameterId": "http_schema",
@@ -113,6 +106,15 @@
113106
"stringValue": "Blub"
114107
}
115108
}
109+
},
110+
{
111+
"databaseId": "78",
112+
"runtimeParameterId": "headers",
113+
"value": {
114+
"literalValue": {
115+
"structValue": {}
116+
}
117+
}
116118
}
117119
]
118120
},
@@ -176,15 +178,6 @@
176178
}
177179
}
178180
},
179-
{
180-
"databaseId": "73",
181-
"runtimeParameterId": "headers",
182-
"value": {
183-
"literalValue": {
184-
"structValue": {}
185-
}
186-
}
187-
},
188181
{
189182
"databaseId": "76",
190183
"runtimeParameterId": "http_schema",
@@ -202,6 +195,15 @@
202195
"stringValue": "Blob"
203196
}
204197
}
198+
},
199+
{
200+
"databaseId": "73",
201+
"runtimeParameterId": "headers",
202+
"value": {
203+
"literalValue": {
204+
"structValue": {}
205+
}
206+
}
205207
}
206208
]
207209
}

0 commit comments

Comments
 (0)