Skip to content

Commit 16928a6

Browse files
committed
test: Add serialize_obelisk_toml_should_produce_correct_config
1 parent 9f01d4c commit 16928a6

4 files changed

Lines changed: 128 additions & 2 deletions

File tree

workflow/deployer-workflow/impl-flyio/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ wit-bindgen.workspace = true
2020
anyhow.workspace = true
2121
wit-bindgen-rust.workspace = true
2222
wit-parser.workspace = true
23+
24+
[dev-dependencies]
25+
insta.workspace = true

workflow/deployer-workflow/impl-flyio/src/lib.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,63 @@ listening_addr = "0.0.0.0:{WEBHOOK_INTERNAL_PORT}"
477477

478478
toml_string
479479
}
480+
481+
#[cfg(test)]
482+
mod tests {
483+
use insta::assert_snapshot;
484+
485+
use crate::{
486+
generated::obelisk_flyio::workflow::types::{
487+
ActivityWasm, ObeliskConfig, Route, WebhookEndpoint, Workflow,
488+
},
489+
serialize_obelisk_toml,
490+
};
491+
492+
#[test]
493+
fn serialize_obelisk_toml_should_produce_correct_config() {
494+
let config = ObeliskConfig {
495+
activity_wasm_list: Some(vec![
496+
ActivityWasm {
497+
name: "stargazers_activity_llm_chatgpt".to_string(),
498+
location_oci: "docker.io/getobelisk/demo_stargazers_activity_llm_openai:2025-09-28@sha256:4b10a66c80bec625a6b0a2e8a4b5192f8a2356eca19c0a6705335771a8b8b1e8".to_string(),
499+
env_vars: Some(vec!["OPENAI_API_KEY".to_string()]),
500+
lock_expiry_seconds: Some(10),
501+
},
502+
ActivityWasm {
503+
name: "stargazers_activity_github_impl".to_string(),
504+
location_oci: "docker.io/getobelisk/demo_stargazers_activity_github_impl:2025-09-28@sha256:8f6fc9b1379b359e085998fa2fd7c966c450327d09770807dfba4b2f75731d72".to_string(),
505+
env_vars: Some(vec!["GITHUB_TOKEN".to_string()]),
506+
lock_expiry_seconds: Some(5),
507+
},
508+
ActivityWasm {
509+
name: "stargazers_activity_db_turso".to_string(),
510+
location_oci: "docker.io/getobelisk/demo_stargazers_activity_db_turso:2025-09-28@sha256:26b08b3d0c6e430944d8187a00bd9817a83ab89e11ba72d15e7533a758addf33".to_string(),
511+
env_vars: Some(vec!["TURSO_TOKEN".to_string(), "TURSO_LOCATION".to_string()]),
512+
lock_expiry_seconds: Some(5),
513+
},
514+
]),
515+
workflow_list: Some(vec![
516+
Workflow {
517+
name: "stargazers_workflow".to_string(),
518+
location_oci: "docker.io/getobelisk/demo_stargazers_workflow:2025-09-28@sha256:678d85e3e2f89d22794fd1ffc0217bf23510e1349ee150a54d5c82cc2ef75834".to_string(),
519+
},
520+
]),
521+
webhook_endpoint_list: Some(vec![
522+
WebhookEndpoint {
523+
name: "stargazers_webhook".to_string(),
524+
location_oci: "docker.io/getobelisk/demo_stargazers_webhook:2025-09-28@sha256:aa4dfa18d1ad7c1623163eeabb41a415ebad5296fca8f3b957987afcdb2a0f40".to_string(),
525+
routes: vec![
526+
Route {
527+
methods: vec!["POST".to_string(), "GET".to_string()],
528+
path: "".to_string(),
529+
},
530+
],
531+
env_vars: Some(vec!["GITHUB_WEBHOOK_SECRET".to_string()]),
532+
},
533+
]),
534+
};
535+
536+
let toml = serialize_obelisk_toml(&config);
537+
assert_snapshot!(toml);
538+
}
539+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
source: workflow/deployer-workflow/impl-flyio/src/lib.rs
3+
expression: toml
4+
---
5+
sqlite.directory = "/volume/obelisk-sqlite"
6+
wasm.cache_directory = "/volume/wasm"
7+
wasm.codegen_cache.directory = "/volumeolume/codegen"
8+
9+
wasm.parallel_compilation = false
10+
wasm.backtrace.persist = false # Speed up execution
11+
12+
api.listening_addr = "[::]:5005"
13+
webui.listening_addr = "[::]:8080"
14+
15+
sqlite.pragma = { "cache_size" = "3000" }
16+
17+
[log.stdout]
18+
enabled = true
19+
level = "WARN,obelisk=info"
20+
21+
[[http_server]]
22+
name = "healthcheck_server"
23+
listening_addr = "0.0.0.0:9091"
24+
25+
[[webhook_endpoint]]
26+
name = "webhook_healthcheck"
27+
location.oci = "docker.io/getobelisk/components_flyio_webhook_healthcheck:2025-10-01@sha256:6fbc11b80b441ae6e642327b1ec0ceba85b2868d85dbce2d99d0d7b14a525c8c"
28+
http_server = "healthcheck_server"
29+
routes = [""]
30+
31+
[[http_server]]
32+
name = "webhook_server"
33+
listening_addr = "0.0.0.0:9090"
34+
35+
36+
[[activity_wasm]]
37+
name = "stargazers_activity_llm_chatgpt"
38+
location.oci = "docker.io/getobelisk/demo_stargazers_activity_llm_openai:2025-09-28@sha256:4b10a66c80bec625a6b0a2e8a4b5192f8a2356eca19c0a6705335771a8b8b1e8"
39+
env_vars = ["OPENAI_API_KEY"]
40+
exec.lock_expiry.seconds = 10
41+
42+
[[activity_wasm]]
43+
name = "stargazers_activity_github_impl"
44+
location.oci = "docker.io/getobelisk/demo_stargazers_activity_github_impl:2025-09-28@sha256:8f6fc9b1379b359e085998fa2fd7c966c450327d09770807dfba4b2f75731d72"
45+
env_vars = ["GITHUB_TOKEN"]
46+
exec.lock_expiry.seconds = 5
47+
48+
[[activity_wasm]]
49+
name = "stargazers_activity_db_turso"
50+
location.oci = "docker.io/getobelisk/demo_stargazers_activity_db_turso:2025-09-28@sha256:26b08b3d0c6e430944d8187a00bd9817a83ab89e11ba72d15e7533a758addf33"
51+
env_vars = ["TURSO_TOKEN", "TURSO_LOCATION"]
52+
exec.lock_expiry.seconds = 5
53+
54+
[[workflow]]
55+
name = "stargazers_workflow"
56+
location.oci = "docker.io/getobelisk/demo_stargazers_workflow:2025-09-28@sha256:678d85e3e2f89d22794fd1ffc0217bf23510e1349ee150a54d5c82cc2ef75834"
57+
58+
[[webhook_endpoint]]
59+
name = "stargazers_webhook"
60+
location.oci = "docker.io/getobelisk/demo_stargazers_webhook:2025-09-28@sha256:aa4dfa18d1ad7c1623163eeabb41a415ebad5296fca8f3b957987afcdb2a0f40"
61+
http_server = "webhook_server"
62+
routes = [{ methods = ["POST", "GET"], route = "" }]
63+
env_vars = ["GITHUB_WEBHOOK_SECRET"]

workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/types.wit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface types {
88
record obelisk-config {
99
activity-wasm-list: option<list<activity-wasm>>,
1010
workflow-list: option<list<workflow>>,
11-
webhook-endpoint-list: option<list<webhok-endpoint>>,
11+
webhook-endpoint-list: option<list<webhook-endpoint>>,
1212
}
1313

1414
record activity-wasm {
@@ -23,7 +23,7 @@ interface types {
2323
location-oci: string,
2424
}
2525

26-
record webhok-endpoint {
26+
record webhook-endpoint {
2727
name: string,
2828
location-oci: string,
2929
routes: list<route>,

0 commit comments

Comments
 (0)