MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / test_project_generator

Function test_project_generator

aiscript/src/project.rs:143–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

141
142 #[test]
143 fn test_project_generator() {
144 // Use tempdir to ensure test files are cleaned up
145 let temp_dir = tempdir().unwrap();
146 let temp_path = temp_dir.path();
147
148 // Create a test project in the temp directory
149 let project_name = "test_project";
150
151 // Create an absolute path for the project
152 let project_path = temp_path.join(project_name);
153
154 // Override the project path for testing
155 let generator = ProjectGenerator {
156 project_name: project_name.to_string(),
157 project_path: project_path.clone(),
158 };
159
160 let result = generator.generate();
161
162 assert!(result.is_ok(), "Project generation failed: {:?}", result);
163
164 // Verify project structure
165 assert!(project_path.exists(), "Project directory not created");
166 assert!(
167 project_path.join("lib").exists(),
168 "lib directory not created"
169 );
170 assert!(
171 project_path.join("routes").exists(),
172 "routes directory not created"
173 );
174 assert!(
175 project_path.join("project.toml").exists(),
176 "project.toml not created"
177 );
178 assert!(
179 project_path.join("routes/index.ai").exists(),
180 "Example file not created"
181 );
182
183 // Verify project.toml content
184 let toml_content = fs::read_to_string(project_path.join("project.toml")).unwrap();
185 assert!(toml_content.contains(&format!("name = \"{}\"", project_name)));
186 assert!(toml_content.contains("version = \"0.1.0\""));
187
188 // Verify example file content
189 let example_content = fs::read_to_string(project_path.join("routes/index.ai")).unwrap();
190 assert!(example_content.contains("get /hello"));
191 }
192
193 #[test]
194 fn test_project_already_exists() {

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected