forked from eyaltoledano/claude-task-master
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-clean-tags.js
More file actions
70 lines (63 loc) · 1.73 KB
/
test-clean-tags.js
File metadata and controls
70 lines (63 loc) · 1.73 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
import fs from 'fs';
import {
createTag,
listTags
} from './scripts/modules/task-manager/tag-management.js';
console.log('=== Testing Tag Management with Clean File ===');
// Create a clean test tasks.json file
const testTasksPath = './test-tasks.json';
const cleanData = {
master: {
tasks: [
{ id: 1, title: 'Test Task 1', status: 'pending' },
{ id: 2, title: 'Test Task 2', status: 'done' }
],
metadata: {
created: new Date().toISOString(),
description: 'Master tag'
}
}
};
// Write clean test file
fs.writeFileSync(testTasksPath, JSON.stringify(cleanData, null, 2));
console.log('Created clean test file');
try {
// Test creating a new tag
console.log('\n--- Testing createTag ---');
await createTag(
testTasksPath,
'test-branch',
{ copyFromCurrent: true, description: 'Test branch' },
{ projectRoot: process.cwd() },
'json'
);
// Read the file and check for corruption
const resultData = JSON.parse(fs.readFileSync(testTasksPath, 'utf8'));
console.log('Keys in result file:', Object.keys(resultData));
console.log('Has _rawTaggedData in file:', !!resultData._rawTaggedData);
if (resultData._rawTaggedData) {
console.log('❌ CORRUPTION DETECTED: _rawTaggedData found in file!');
} else {
console.log('✅ SUCCESS: No _rawTaggedData corruption in file');
}
// Test listing tags
console.log('\n--- Testing listTags ---');
const tagList = await listTags(
testTasksPath,
{},
{ projectRoot: process.cwd() },
'json'
);
console.log(
'Found tags:',
tagList.tags.map((t) => t.name)
);
} catch (error) {
console.error('Error during test:', error.message);
} finally {
// Clean up test file
if (fs.existsSync(testTasksPath)) {
fs.unlinkSync(testTasksPath);
console.log('\nCleaned up test file');
}
}