-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2154 from fermyon/variables-test
Add a runtime test for the variables interface
- Loading branch information
Showing
7 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "variables" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
helper = { path = "../helper" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Variables | ||
|
||
Tests the variable interface. | ||
|
||
## Expectations | ||
|
||
This test component expects the following to be true: | ||
* Only the variable named "variable" is defined with value "value" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use helper::ensure_matches; | ||
|
||
use bindings::fermyon::spin2_0_0::variables::{get, Error}; | ||
|
||
helper::define_component!(Component); | ||
|
||
impl Component { | ||
fn main() -> Result<(), String> { | ||
ensure_matches!(get("variable"), Ok(val) if val == "value"); | ||
ensure_matches!(get("non_existent"), Err(Error::Undefined(_))); | ||
|
||
ensure_matches!(get("invalid-name"), Err(Error::InvalidName(_))); | ||
ensure_matches!(get("invalid!name"), Err(Error::InvalidName(_))); | ||
ensure_matches!(get("4invalidname"), Err(Error::InvalidName(_))); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "variables" | ||
authors = ["Fermyon Engineering <[email protected]>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "{{variables}}" | ||
|
||
[component.test.variables] | ||
variable = "value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters