Skip to content

Commit

Permalink
Support optional result fields
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Apr 1, 2024
1 parent 3bb86bc commit d6c999b
Show file tree
Hide file tree
Showing 22 changed files with 469 additions and 2,279 deletions.
7 changes: 7 additions & 0 deletions examples/simple/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ build:
run:
just build
cargo run -p pulumi_wasm_runner -- run --wasm ../../target/wasm32-wasi/debug/composed.wasm

[windows]
local-test:
#!pwsh
$env:PULUMI_CONFIG_PASSPHRASE=" "
pulumi destroy -y
pulumi up -y
4 changes: 4 additions & 0 deletions examples/simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ fn test_main() -> Result<(), Error> {
special: None.into(),
upper: None.into(),
});

let t = random_string.result.map(|s| format!("Result: {s}"));

add_export("result", random_string.result);
add_export("transformed_result", t);
Ok(())
}
7 changes: 7 additions & 0 deletions examples/simple/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ fn test_integration() -> Result<(), anyhow::Error> {
.as_str()
.ok_or(anyhow!("[result] is not a string"))?;

let transformed_result = stack
.pointer("/transformed_result")
.ok_or(anyhow!("Cannot find [transformed_result] in stack export"))?
.as_str()
.ok_or(anyhow!("[transformed_result] is not a string"))?;

assert_eq!(result.len(), 36);
assert_eq!(transformed_result, format!("Result: {}", result));

Ok(())
}
1,684 changes: 0 additions & 1,684 deletions providers/pulumi_wasm_provider_random/src/bindings.rs

This file was deleted.

Loading

0 comments on commit d6c999b

Please sign in to comment.