-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-basic.js
More file actions
71 lines (55 loc) · 2.57 KB
/
test-basic.js
File metadata and controls
71 lines (55 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env node
const { TemplateManager, ProjectDetector, GitManager } = require('./dist/index.js');
async function testBasicFunctionality() {
console.log('🧪 Testing basic dcsandbox functionality...\n');
try {
// Test Template Manager
console.log('📋 Testing Template Manager...');
const templateManager = new TemplateManager();
// Create builtin templates
await templateManager.createBuiltinTemplates();
console.log('✅ Built-in templates created');
// List templates
const templates = await templateManager.listTemplates();
console.log(`✅ Found ${templates.length} templates:`);
templates.forEach(t => console.log(` - ${t.name} (${t.builtin ? 'built-in' : 'custom'})`));
// Get a specific template
const nodeTemplate = await templateManager.getTemplate('node');
if (nodeTemplate) {
console.log('✅ Node.js template loaded successfully');
} else {
console.log('❌ Failed to load Node.js template');
}
console.log();
// Test Project Detector
console.log('🔍 Testing Project Detector...');
const projectDetector = new ProjectDetector();
// Test detection with current directory
const detection = await projectDetector.detectProject('.');
console.log(`✅ Project detection result: ${detection.language} (confidence: ${detection.confidence})`);
console.log(` Template: ${detection.template}`);
if (detection.framework) console.log(` Framework: ${detection.framework}`);
if (detection.packageManager) console.log(` Package Manager: ${detection.packageManager}`);
console.log();
// Test Git Manager
console.log('🌐 Testing Git Manager...');
const gitManager = new GitManager();
// Test URL parsing
const repoInfo = gitManager.extractRepoInfo('https://github.com/user/repo.git');
console.log('✅ Git URL parsing works');
console.log(` Owner: ${repoInfo.owner}, Repo: ${repoInfo.repo}, Provider: ${repoInfo.provider}`);
// Test validation (this will work even without network)
console.log('✅ Git validation functions available');
console.log();
console.log('🎉 All basic tests passed! The core functionality is working.');
console.log();
console.log('Next steps:');
console.log('1. Install Docker or Podman');
console.log('2. Try creating a sandbox: npm run dev -- create --name test-sandbox');
console.log('3. List sandboxes: npm run dev -- list');
} catch (error) {
console.error('❌ Test failed:', error.message);
process.exit(1);
}
}
testBasicFunctionality();