generate appname for template based tests
Signed-off-by: Rajat Jindal <rajatjindal83@gmail.com>
This commit is contained in:
parent
81869ca6a8
commit
80aa927704
|
@ -1,11 +1,5 @@
|
|||
**/target
|
||||
**/node_modules
|
||||
**/http-go-test
|
||||
**/http-c-test
|
||||
**/http-rust-test
|
||||
**/http-zig-test
|
||||
**/http-grain-test
|
||||
**/http-ts-test
|
||||
**/http-js-test
|
||||
tests/testcases/*-generated
|
||||
**/spin-plugin-update.lock
|
||||
**/package-lock.json
|
|
@ -9,12 +9,6 @@ main.wasm
|
|||
tests/**/Cargo.lock
|
||||
crates/**/Cargo.lock
|
||||
Cargo.lock
|
||||
http-go-test*
|
||||
http-c-test*
|
||||
http-rust-test*
|
||||
http-zig-test*
|
||||
http-grain-test*
|
||||
http-ts-test*
|
||||
http-js-test*
|
||||
tests/testcases/*-generated
|
||||
spin-plugin-update.lock
|
||||
package-lock.json
|
||||
|
|
|
@ -53,7 +53,7 @@ impl Controller for SpinUp {
|
|||
|
||||
match utils::get_output(&mut child).await {
|
||||
Ok(output) => print!("this output is {:?} until here", output),
|
||||
Err(error) => panic!("problem deploying app {:?}", error),
|
||||
Err(error) => panic!("problem running app {:?}", error),
|
||||
};
|
||||
|
||||
Ok(AppInstance::new_with_process(
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct TestCase {
|
|||
pub name: String,
|
||||
|
||||
/// name of the app under test
|
||||
pub appname: String,
|
||||
pub appname: Option<String>,
|
||||
|
||||
/// optional
|
||||
/// template to use to create new app
|
||||
|
@ -70,18 +70,6 @@ impl TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// install spin templates from git repo.
|
||||
// if template_install_args is provided uses that
|
||||
// defaults to spin repo
|
||||
let template_install_args = match &self.template_install_args {
|
||||
Some(args) => args.iter().map(|s| s as &str).collect(),
|
||||
None => vec!["--git", "https://github.com/fermyon/spin"],
|
||||
};
|
||||
|
||||
controller
|
||||
.template_install(template_install_args)
|
||||
.context("installing templates")?;
|
||||
|
||||
// install spin plugins if requested in testcase config
|
||||
if let Some(plugins) = &self.plugins {
|
||||
controller
|
||||
|
@ -89,14 +77,33 @@ impl TestCase {
|
|||
.context("installing plugins")?;
|
||||
}
|
||||
|
||||
let appdir = spin::appdir(&self.appname);
|
||||
let appname = match &self.appname {
|
||||
Some(appname) => appname.to_owned(),
|
||||
None => format!("{}-generated", self.template.as_ref().unwrap()),
|
||||
};
|
||||
|
||||
let appdir = spin::appdir(appname.as_str());
|
||||
|
||||
// cleanup existing dir for testcase project code. cleaned up only if testcase is a template based test
|
||||
if self.template.is_some() {
|
||||
// appname = format!("{}-generated", &self.template.unwrap()).as_mut();
|
||||
// appdir = spin::appdir(appname.as_str());
|
||||
|
||||
// install spin templates from git repo. if template_install_args is provided uses that
|
||||
// defaults to spin repo
|
||||
let template_install_args = match &self.template_install_args {
|
||||
Some(args) => args.iter().map(|s| s as &str).collect(),
|
||||
None => vec!["--git", "https://github.com/fermyon/spin"],
|
||||
};
|
||||
|
||||
controller
|
||||
.template_install(template_install_args)
|
||||
.context("installing templates")?;
|
||||
|
||||
if fs::remove_dir_all(&appdir).is_err() {};
|
||||
|
||||
controller
|
||||
.new_app(self.template.as_ref().unwrap(), &self.appname)
|
||||
.new_app(self.template.as_ref().unwrap(), &appname)
|
||||
.context("creating new app")?;
|
||||
}
|
||||
|
||||
|
@ -109,14 +116,11 @@ impl TestCase {
|
|||
}
|
||||
|
||||
// run spin build
|
||||
controller.build_app(&self.appname).context("builing app")?;
|
||||
controller.build_app(&appname).context("builing app")?;
|
||||
|
||||
// run `spin up` (or `spin deploy` for cloud).
|
||||
// `AppInstance` has some basic info about the running app like base url, routes (only for cloud) etc.
|
||||
let app = controller
|
||||
.run_app(&self.appname)
|
||||
.await
|
||||
.context("deploying app")?;
|
||||
let app = controller.run_app(&appname).await.context("running app")?;
|
||||
|
||||
// run test specific assertions
|
||||
let metadata = app.metadata;
|
||||
|
|
|
@ -18,7 +18,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-go template".to_string(),
|
||||
appname: "http-go-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-go".to_string()),
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -43,7 +43,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-c template".to_string(),
|
||||
appname: "http-c-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-c".to_string()),
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -63,7 +63,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-rust-template".to_string(),
|
||||
appname: "http-rust-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-rust".to_string()),
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -83,7 +83,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-zig-template".to_string(),
|
||||
appname: "http-zig-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-zig".to_string()),
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -103,7 +103,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-grain-template".to_string(),
|
||||
appname: "http-grain-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-grain".to_string()),
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -128,7 +128,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-ts-template".to_string(),
|
||||
appname: "http-ts-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-ts".to_string()),
|
||||
template_install_args: Some(vec![
|
||||
"--git".to_string(),
|
||||
|
@ -157,7 +157,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-js-template".to_string(),
|
||||
appname: "http-js-test".to_string(),
|
||||
appname: None,
|
||||
template: Some("http-js".to_string()),
|
||||
template_install_args: Some(vec![
|
||||
"--git".to_string(),
|
||||
|
@ -220,7 +220,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "assets-test".to_string(),
|
||||
appname: "assets-test".to_string(),
|
||||
appname: Some("assets-test".to_string()),
|
||||
template: None,
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -272,7 +272,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "simple-spin-rust-test".to_string(),
|
||||
appname: "simple-spin-rust-test".to_string(),
|
||||
appname: Some("simple-spin-rust-test".to_string()),
|
||||
template: None,
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -306,7 +306,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "headers-env-routes-test".to_string(),
|
||||
appname: "headers-env-routes-test".to_string(),
|
||||
appname: Some("headers-env-routes-test".to_string()),
|
||||
template: None,
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -340,7 +340,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "headers-dynamic-env-test".to_string(),
|
||||
appname: "headers-dynamic-env-test".to_string(),
|
||||
appname: Some("headers-dynamic-env-test".to_string()),
|
||||
template: None,
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
@ -377,7 +377,7 @@ pub mod all {
|
|||
|
||||
let tc = TestCase {
|
||||
name: "http-rust-outbound-mysql".to_string(),
|
||||
appname: "http-rust-outbound-mysql".to_string(),
|
||||
appname: Some("http-rust-outbound-mysql".to_string()),
|
||||
template: None,
|
||||
template_install_args: None,
|
||||
assertions: checks,
|
||||
|
|
Loading…
Reference in New Issue