Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions worker/src/components/security/__tests__/naabu.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import { describe, it, expect, beforeAll, afterEach, vi } from 'bun:test';
import { describe, it, expect, beforeAll, afterEach, vi, mock } from 'bun:test';
import * as sdk from '@shipsec/component-sdk';
import { componentRegistry } from '../../index';
import type { NaabuInput, NaabuOutput } from '../naabu';

// Mock IsolatedContainerVolume BEFORE any component imports.
// ../../index eagerly imports naabu.ts which pulls in the real
// IsolatedContainerVolume; using a dynamic import in beforeAll()
// ensures the mock is registered first.
mock.module('../../../utils/isolated-volume', () => ({
IsolatedContainerVolume: class {
async initialize() {
return 'mock-volume';
}
getVolumeConfig(containerPath = '/inputs', readOnly = true) {
return { source: 'mock-volume', target: containerPath, readOnly };
}
async cleanup() {}
},
}));

let componentRegistry: typeof import('@shipsec/component-sdk').componentRegistry;

describe('naabu component', () => {
beforeAll(async () => {
await import('../../index');
({ componentRegistry } = await import('../../index'));
});

afterEach(() => {
Expand Down