Skip to content

Commit 0769548

Browse files
authored
Merge pull request #12 from OGMatrix/dev
Applying fixes to prod
2 parents 0686072 + 600cbb2 commit 0769548

2 files changed

Lines changed: 11 additions & 88 deletions

File tree

src/cli/manage.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ async function fetchJson(url: string): Promise<unknown> {
221221
};
222222
https
223223
.get(url, options, (res) => {
224+
// Handle redirects (GitHub release assets redirect to the actual download URL)
225+
if (res.statusCode === 301 || res.statusCode === 302) {
226+
if (!res.headers.location) {
227+
return reject(new Error('Redirect location missing'));
228+
}
229+
res.resume();
230+
fetchJson(res.headers.location).then(resolve).catch(reject);
231+
return;
232+
}
233+
224234
if (res.statusCode !== 200) {
225235
res.resume();
226236
return reject(new Error(`Request failed with status code ${res.statusCode}`));

src/index.test.ts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Tests cover: DbVersioning, Tool Handlers, Utility Functions
44
*/
55

6-
import { describe, it, expect, vi, beforeEach, afterEach, type Mock } from 'vitest';
6+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
77
import fs from 'fs';
88

99
// ============================================================================
@@ -809,90 +809,3 @@ describe('Version Comparison Edge Cases', () => {
809809
expect(versioning.compareVersions('1.0.0', '2.0.0')).toBe(-1);
810810
});
811811
});
812-
813-
// ============================================================================
814-
// ModExamplesService Tests
815-
// ============================================================================
816-
817-
describe('ModExamplesService', () => {
818-
let ModExamplesService: typeof import('./services/mod-examples-service.js').ModExamplesService;
819-
let mockDb: { prepare: Mock; close: Mock };
820-
let mockPrepare: Mock;
821-
let mockGet: Mock;
822-
let mockAll: Mock;
823-
824-
beforeEach(async () => {
825-
vi.resetModules();
826-
827-
mockGet = vi.fn();
828-
mockAll = vi.fn();
829-
mockPrepare = vi.fn().mockReturnValue({
830-
get: mockGet,
831-
all: mockAll,
832-
});
833-
mockDb = {
834-
prepare: mockPrepare,
835-
close: vi.fn(),
836-
};
837-
838-
vi.doMock('better-sqlite3', () => {
839-
return {
840-
default: vi.fn(function () {
841-
return mockDb;
842-
}),
843-
};
844-
});
845-
846-
const module = await import('./services/mod-examples-service.js');
847-
ModExamplesService = module.ModExamplesService;
848-
});
849-
850-
afterEach(() => {
851-
vi.restoreAllMocks();
852-
});
853-
854-
it('searchExamples should return empty array when no results', () => {
855-
mockAll.mockReturnValue([]);
856-
const service = new ModExamplesService();
857-
const results = service.searchExamples({ query: 'test' });
858-
expect(results).toEqual([]);
859-
});
860-
861-
it('searchExamples should parse JSON fields correctly', () => {
862-
const mockRow = {
863-
id: 1,
864-
mod_name: 'TestMod',
865-
mod_repo: 'test/repo',
866-
file_path: 'src/Test.java',
867-
file_url: 'http://example.com',
868-
start_line: 1,
869-
end_line: 10,
870-
title: 'Test Example',
871-
code: 'code',
872-
language: 'java',
873-
caption: 'caption',
874-
explanation: 'explanation',
875-
pattern_type: 'mixin',
876-
complexity: 'beginner',
877-
category: 'items',
878-
categoryName: 'Items',
879-
bestPractices: '["practice"]',
880-
potentialPitfalls: '["pitfall"]',
881-
useCases: '["usecase"]',
882-
keywords: '["keyword"]',
883-
minecraftConcepts: '["concept"]',
884-
qualityScore: 100,
885-
isFeatured: 1,
886-
tags: '["tag"]',
887-
imports: '[{"path":"p","type":"t","isCritical":true}]',
888-
apiReferences: '[{"className":"c","apiType":"a"}]',
889-
};
890-
mockAll.mockReturnValue([mockRow]);
891-
892-
const service = new ModExamplesService();
893-
const results = service.searchExamples({ query: 'test' });
894-
895-
expect(results[0].bestPractices).toEqual(['practice']);
896-
expect(results[0].imports).toHaveLength(1);
897-
});
898-
});

0 commit comments

Comments
 (0)