Skip to content

Commit 23174cb

Browse files
committed
Enable spin add to add different trigger types
Signed-off-by: itowlson <[email protected]>
1 parent c96a090 commit 23174cb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

crates/templates/src/manager.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ mod tests {
11251125
}
11261126

11271127
#[tokio::test]
1128-
async fn cannot_add_component_that_does_not_match_trigger() {
1128+
async fn can_add_component_with_different_trigger() {
11291129
let temp_dir = tempdir().unwrap();
11301130
let store = TemplateStore::new(temp_dir.path());
11311131
let manager = TemplateManager { store };
@@ -1191,12 +1191,14 @@ mod tests {
11911191
accept_defaults: false,
11921192
};
11931193

1194-
template
1195-
.run(options)
1196-
.silent()
1197-
.await
1198-
.expect_err("Expected to fail to add component, but it succeeded");
1194+
template.run(options).silent().await.unwrap();
11991195
}
1196+
1197+
let spin_toml = tokio::fs::read_to_string(&spin_toml_path).await.unwrap();
1198+
assert!(spin_toml.contains("[[trigger.redis]]"));
1199+
assert!(spin_toml.contains("[[trigger.http]]"));
1200+
assert!(spin_toml.contains("[component.my-multi-project]"));
1201+
assert!(spin_toml.contains("[component.hello]"));
12001202
}
12011203

12021204
#[tokio::test]

crates/templates/src/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Run {
217217
TemplateVariantInfo::NewApplication => Ok(()),
218218
TemplateVariantInfo::AddComponent { manifest_path } => {
219219
match crate::app_info::AppInfo::from_file(manifest_path) {
220-
Some(Ok(app_info)) => self
220+
Some(Ok(app_info)) if app_info.manifest_format() == 1 => self
221221
.template
222222
.check_compatible_trigger(app_info.trigger_type()),
223223
_ => Ok(()), // Fail forgiving - don't block the user if things are under construction

0 commit comments

Comments
 (0)