mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 20:17:03 +00:00
fix(cache): use ~/.ccs/cache/ for usage and update-check files
- usage-disk-cache.ts: usage-cache.json → cache/usage.json - update-checker.ts: update-check.json → cache/update-check.json - Both ensure cache directory exists before writing - Update tests to use new cache paths
This commit is contained in:
1 parent
0aa9131642
commit
790ac3c862
3 files changed
+18
-17
No files matched your search
@@ -275,7 +275,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
latest_version: null,
|
||||
dismissed_version: null
|
||||
};
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'cache', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
});
|
||||
|
||||
it('should use latest tag when targetTag is "latest"', async function () {
|
||||
@@ -362,7 +362,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
await updateCheckerModule.checkForUpdates('5.4.0', true, 'npm', 'dev');
|
||||
|
||||
// Check cache was updated with dev version
|
||||
const cachePath = path.join(os.homedir(), '.ccs', 'update-check.json');
|
||||
const cachePath = path.join(os.homedir(), '.ccs', 'cache', 'update-check.json');
|
||||
const cacheData = JSON.parse(mockFileSystem[cachePath]);
|
||||
|
||||
assert.strictEqual(cacheData.latest_version, '5.5.0');
|
||||
@@ -376,7 +376,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
latest_version: '5.5.0',
|
||||
dismissed_version: null
|
||||
};
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'cache', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
|
||||
// Call with force=false to use cache
|
||||
const result = await updateCheckerModule.checkForUpdates('5.4.0', false, 'npm', 'dev');
|
||||
@@ -465,7 +465,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
describe('Cache functionality', function () {
|
||||
it('should create cache directory if not exists', async function () {
|
||||
// Ensure no cache exists
|
||||
const cacheDir = path.join(os.homedir(), '.ccs');
|
||||
const cacheDir = path.join(os.homedir(), '.ccs', 'cache');
|
||||
delete mockFileSystem[cacheDir];
|
||||
|
||||
await updateCheckerModule.checkForUpdates('5.4.0', true, 'npm', 'latest');
|
||||
@@ -481,7 +481,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
latest_version: '5.5.0',
|
||||
dismissed_version: '5.5.0'
|
||||
};
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'cache', 'update-check.json')] = JSON.stringify(cacheData);
|
||||
|
||||
const result = await updateCheckerModule.checkForUpdates('5.4.1', false, 'npm', 'dev');
|
||||
|
||||
@@ -492,7 +492,7 @@ describe('Beta Channel Implementation (Phase 3)', function () {
|
||||
|
||||
it('should handle corrupted cache gracefully', async function () {
|
||||
// Set up corrupted cache
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'update-check.json')] = 'invalid json';
|
||||
mockFileSystem[path.join(os.homedir(), '.ccs', 'cache', 'update-check.json')] = 'invalid json';
|
||||
|
||||
// Should not throw error
|
||||
const result = await updateCheckerModule.checkForUpdates('5.4.0', true, 'npm', 'latest');
|
||||
|
||||
Reference in new issue
Block a user