Skip to content

Commit

Permalink
Merge pull request #2207 from itowlson/templates-add-both-components-…
Browse files Browse the repository at this point in the history
…and-variables

Test that variables and components can be added in the same template
  • Loading branch information
itowlson authored Jan 2, 2024
2 parents 2bf1305 + 55c9787 commit e436b93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/templates/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,13 @@ mod tests {
}

let spin_toml = tokio::fs::read_to_string(&spin_toml_path).await.unwrap();

assert!(spin_toml.contains("[variables]\nsecret"));
assert!(spin_toml.contains("url = { default = \"https://service.example.com\" }"));

assert!(spin_toml.contains("[component.insertvars]"));
assert!(spin_toml.contains("[component.insertvars.variables]"));
assert!(spin_toml.contains("kv_credentials = \"{{ secret }}\""));
}

#[tokio::test]
Expand Down Expand Up @@ -1106,7 +1111,7 @@ mod tests {
manifest_path: spin_toml_path.clone(),
},
output_path: PathBuf::from(output_dir),
name: "insertvars".to_owned(),
name: "insertvarsagain".to_owned(),
values,
accept_defaults: false,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[component.{{project-name | kebab_case}}]
source = { url = "https://example.com/spin-kv-explorer.wasm", digest = "sha256:12345" }
id = "{{ project-name | kebab_case }}"
key_value_stores = ["default"]
[component.{{project-name | kebab_case}}.variables]
{% raw %}kv_credentials = "{{ secret }}"{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ supported = false

[add_component]
[add_component.snippets]
component = "component.txt"
variables = "variables.txt"

[parameters]
Expand Down

0 comments on commit e436b93

Please sign in to comment.