| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | const web_test_path = os.join_path(os.vtmp_dir(), 'test_vcreate_web') |
| 6 | |
| 7 | fn test_web_template_uses_veb() { |
| 8 | os.rmdir_all(web_test_path) or {} |
| 9 | defer { |
| 10 | os.rmdir_all(web_test_path) or {} |
| 11 | } |
| 12 | os.mkdir_all(web_test_path)! |
| 13 | old_wd := os.getwd() |
| 14 | defer { |
| 15 | os.chdir(old_wd) or {} |
| 16 | } |
| 17 | os.chdir(web_test_path)! |
| 18 | project_name := 'my_web_project' |
| 19 | project_path := os.join_path(web_test_path, project_name) |
| 20 | mut c := Create{ |
| 21 | name: project_name |
| 22 | description: 'My Awesome V Web Project.' |
| 23 | version: '0.1.0' |
| 24 | license: 'MIT' |
| 25 | new_dir: true |
| 26 | template: .web |
| 27 | } |
| 28 | c.create_files_and_directories() |
| 29 | c.write_vmod() |
| 30 | main_v := os.read_file(os.join_path(project_path, 'main.v'))! |
| 31 | assert main_v.contains('import veb') |
| 32 | assert main_v.contains('\$veb.html()') |
| 33 | template_html := os.read_file(os.join_path(project_path, 'templates', 'index.html'))! |
| 34 | assert template_html.contains('veb starter') |
| 35 | os.chdir(project_path)! |
| 36 | res := os.execute('${os.quoted_path(@VEXE)} .') |
| 37 | assert res.exit_code == 0, res.output |
| 38 | } |
| 39 | |