diff --git a/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Postgres.snap b/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Postgres.snap index fc133c56..69809841 100644 --- a/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Postgres.snap +++ b/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Postgres.snap @@ -1,7 +1,6 @@ --- source: tests/templates/db.rs expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())" -snapshot_kind: text --- Mapping { "uri": Mapping { @@ -37,5 +36,5 @@ Mapping { }, "auto_migrate": Bool(true), "dangerously_truncate": Bool(true), - "dangerously_recreate": Bool(false), + "dangerously_recreate": Bool(true), } diff --git a/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Sqlite.snap b/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Sqlite.snap index b45b01b9..104dc69e 100644 --- a/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Sqlite.snap +++ b/loco-new/tests/templates/snapshots/r#mod__templates__db__config_test_yaml_config_database_Sqlite.snap @@ -1,7 +1,6 @@ --- source: tests/templates/db.rs expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())" -snapshot_kind: text --- Mapping { "uri": Mapping { @@ -37,5 +36,5 @@ Mapping { }, "auto_migrate": Bool(true), "dangerously_truncate": Bool(true), - "dangerously_recreate": Bool(false), + "dangerously_recreate": Bool(true), } diff --git a/loco-new/tests/wizard/new.rs b/loco-new/tests/wizard/new.rs index eaf6a2c3..f57aa90a 100644 --- a/loco-new/tests/wizard/new.rs +++ b/loco-new/tests/wizard/new.rs @@ -21,37 +21,55 @@ fn test_all_combinations( #[values(AssetsOption::Serverside, AssetsOption::Clientside, AssetsOption::None)] asset: AssetsOption, ) { - test_combination(db, background, asset); + test_combination(db, background, asset, false); } // when running locally set LOCO_DEV_MODE_PATH= #[test] fn test_starter_combinations() { // lightweight service - test_combination(DBOption::None, BackgroundOption::None, AssetsOption::None); + test_combination( + DBOption::None, + BackgroundOption::None, + AssetsOption::None, + true, + ); // REST API test_combination( DBOption::Sqlite, BackgroundOption::Async, AssetsOption::None, + true, ); // SaaS, serverside test_combination( DBOption::Sqlite, BackgroundOption::Async, AssetsOption::Serverside, + true, ); // SaaS, clientside test_combination( DBOption::Sqlite, BackgroundOption::Async, AssetsOption::Clientside, + true, ); // test only DB - test_combination(DBOption::Sqlite, BackgroundOption::None, AssetsOption::None); + test_combination( + DBOption::Sqlite, + BackgroundOption::None, + AssetsOption::None, + true, + ); } -fn test_combination(db: DBOption, background: BackgroundOption, asset: AssetsOption) { +fn test_combination( + db: DBOption, + background: BackgroundOption, + asset: AssetsOption, + test_generator: bool, +) { let test_dir = tree_fs::TreeBuilder::default().drop(true); let executor = FileSystem::new(&PathBuf::from("base_template"), &test_dir.root); @@ -83,119 +101,121 @@ fn test_combination(db: DBOption, background: BackgroundOption, asset: AssetsOpt .run_test() .expect("run test after create new project"); - // Generate API controller - tester.run_generate(&vec![ - "controller", - "notes_api", - "--api", - "create_note", - "get_note", - ]); - - // Generate HTMX controller - tester.run_generate(&vec![ - "controller", - "notes_htmx", - "--htmx", - "create_note", - "get_note", - ]); - - // Generate HTML controller - tester.run_generate(&vec![ - "controller", - "notes_html", - "--html", - "create_note", - "get_note", - ]); - - // Generate Task - tester.run_generate(&vec!["task", "list_users"]); - - // Generate Scheduler - tester.run_generate(&vec!["scheduler"]); - - if background.enable() { - // Generate Worker - tester.run_generate(&vec!["worker", "cleanup"]); - } - - if settings.mailer { - // Generate Mailer - tester.run_generate(&vec!["mailer", "user_mailer"]); - } - - // Generate deployment nginx - tester.run_generate(&vec!["deployment", "--kind", "nginx"]); - - // Generate deployment nginx - tester.run_generate(&vec!["deployment", "--kind", "docker"]); - - if db.enable() { - // Generate Model - if !settings.auth { - tester.run_generate(&vec!["model", "users", "name:string", "email:string"]); - } - tester.run_generate(&vec!["model", "movies", "title:string", "user:references"]); - - // Generate HTMX Scaffold + if test_generator { + // Generate API controller tester.run_generate(&vec![ - "scaffold", - "movies_htmx", - "title:string", - "user:references", - "--htmx", + "controller", + "notes_api", + "--api", + "create_note", + "get_note", ]); - // Generate HTML Scaffold + // Generate HTMX controller tester.run_generate(&vec![ - "scaffold", - "movies_html", - "title:string", - "user:references", - "--html", + "controller", + "notes_htmx", + "--htmx", + "create_note", + "get_note", ]); - // Generate API Scaffold + // Generate HTML controller tester.run_generate(&vec![ - "scaffold", - "movies_api", - "title:string", - "user:references", - "--api", + "controller", + "notes_html", + "--html", + "create_note", + "get_note", ]); - // Generate CreatePosts migration - tester.run_generate_migration(&vec![ - "CreatePosts", - "title:string", - "user:references", - "movies:references", - ]); + // Generate Task + tester.run_generate(&vec!["task", "list_users"]); - // Generate AddNameAndAgeToUsers migration - tester.run_generate_migration(&vec![ - "AddNameAndAgeToUsers", - "first_name:string", - "age:int", - ]); + // Generate Scheduler + tester.run_generate(&vec!["scheduler"]); - // Generate AddNameAndAgeToUsers migration - tester.run_generate_migration(&vec![ - "RemoveNameAndAgeFromUsers", - "first_name:string", - "age:int", - ]); + if background.enable() { + // Generate Worker + tester.run_generate(&vec!["worker", "cleanup"]); + } - // Generate AddUserRefToPosts migration - // TODO:: not working on sqlite. - // - thread 'main' panicked at 'Sqlite doesn't support multiple alter options' - // - Sqlite does not support modification of foreign key constraints to existing - // tester.run_generate_migration(&vec!["AddUserRefToPosts", "movies:references"]); + if settings.mailer { + // Generate Mailer + tester.run_generate(&vec!["mailer", "user_mailer"]); + } - // Generate CreateJoinTableUsersAndGroups migration - tester.run_generate_migration(&vec!["CreateJoinTableUsersAndGroups", "count:int"]); + // Generate deployment nginx + tester.run_generate(&vec!["deployment", "--kind", "nginx"]); + + // Generate deployment nginx + tester.run_generate(&vec!["deployment", "--kind", "docker"]); + + if db.enable() { + // Generate Model + if !settings.auth { + tester.run_generate(&vec!["model", "users", "name:string", "email:string"]); + } + tester.run_generate(&vec!["model", "movies", "title:string", "user:references"]); + + // Generate HTMX Scaffold + tester.run_generate(&vec![ + "scaffold", + "movies_htmx", + "title:string", + "user:references", + "--htmx", + ]); + + // Generate HTML Scaffold + tester.run_generate(&vec![ + "scaffold", + "movies_html", + "title:string", + "user:references", + "--html", + ]); + + // Generate API Scaffold + tester.run_generate(&vec![ + "scaffold", + "movies_api", + "title:string", + "user:references", + "--api", + ]); + + // Generate CreatePosts migration + tester.run_generate_migration(&vec![ + "CreatePosts", + "title:string", + "user:references", + "movies:references", + ]); + + // Generate AddNameAndAgeToUsers migration + tester.run_generate_migration(&vec![ + "AddNameAndAgeToUsers", + "first_name:string", + "age:int", + ]); + + // Generate AddNameAndAgeToUsers migration + tester.run_generate_migration(&vec![ + "RemoveNameAndAgeFromUsers", + "first_name:string", + "age:int", + ]); + + // Generate AddUserRefToPosts migration + // TODO:: not working on sqlite. + // - thread 'main' panicked at 'Sqlite doesn't support multiple alter options' + // - Sqlite does not support modification of foreign key constraints to existing + // tester.run_generate_migration(&vec!["AddUserRefToPosts", "movies:references"]); + + // Generate CreateJoinTableUsersAndGroups migration + tester.run_generate_migration(&vec!["CreateJoinTableUsersAndGroups", "count:int"]); + } } }