Skip to content

Commit f9663c2

Browse files
vdiezclaude
andcommitted
Fix test imports after deps.ts removal
Update test files to import interfaces from their respective source modules instead of the deleted deps.ts file. Remove export from interfaces that are only used internally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 09f4f9d commit f9663c2

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

src/properties.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ import {
5252
ScannerProperty,
5353
} from './types';
5454

55-
export interface PropertiesFsDeps {
55+
interface PropertiesFsDeps {
5656
readFileSync: typeof fs.readFileSync;
5757
existsSync: typeof fs.existsSync;
5858
}
5959

60-
export interface PropertiesProcessDeps {
60+
interface PropertiesProcessDeps {
6161
platform: NodeJS.Platform;
6262
arch: NodeJS.Architecture;
6363
env: NodeJS.ProcessEnv;

test/unit/java.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ import axios from 'axios';
2323
import MockAdapter from 'axios-mock-adapter';
2424
import { LogLevel } from '../../src/logging';
2525
import { API_V2_JRE_ENDPOINT, SONARQUBE_JRE_PROVISIONING_MIN_VERSION } from '../../src/constants';
26-
import { FsDeps } from '../../src/deps';
27-
import { fetchJRE, fetchServerVersion, serverSupportsJREProvisioning } from '../../src/java';
26+
import {
27+
fetchJRE,
28+
fetchServerVersion,
29+
serverSupportsJREProvisioning,
30+
JavaFsDeps,
31+
} from '../../src/java';
2832
import * as request from '../../src/request';
2933
import {
3034
AnalysisJresResponseType,
@@ -204,13 +208,13 @@ describe('java', () => {
204208
const mockDownload = mock.fn(() => Promise.resolve());
205209
const mockValidateChecksum = mock.fn(() => Promise.reject(new Error('Checksum mismatch')));
206210
const mockRemove = mock.fn(() => Promise.resolve());
207-
const mockFsDeps: Partial<FsDeps> = {
211+
const mockFsDeps: Partial<JavaFsDeps> = {
208212
remove: mockRemove,
209213
};
210214

211215
await assert.rejects(async () => {
212216
await fetchJRE(MOCKED_PROPERTIES, {
213-
fsDeps: mockFsDeps as FsDeps,
217+
fsDeps: mockFsDeps as JavaFsDeps,
214218
getCacheFileLocationFn: mockGetCacheFileLocation,
215219
getCacheDirectoriesFn: mockGetCacheDirectories,
216220
downloadFn: mockDownload,

test/unit/platform.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import { describe, it, mock, beforeEach } from 'node:test';
2222
import assert from 'node:assert';
2323
import * as platform from '../../src/platform';
24-
import { FsDeps, ProcessDeps } from '../../src/deps';
24+
import { PlatformFsDeps, PlatformProcessDeps } from '../../src/platform';
2525

2626
// Mock logging to suppress output
2727
const mockLog = mock.fn();
2828
mock.method(console, 'log', mockLog);
2929

30-
function createMockProcessDeps(overrides: Partial<ProcessDeps> = {}): ProcessDeps {
30+
function createMockProcessDeps(overrides: Partial<PlatformProcessDeps> = {}): PlatformProcessDeps {
3131
return {
3232
platform: 'linux',
3333
arch: 'x64',
@@ -37,14 +37,14 @@ function createMockProcessDeps(overrides: Partial<ProcessDeps> = {}): ProcessDep
3737
};
3838
}
3939

40-
function createMockFsDeps(readFileSyncResult?: string | Error): Partial<FsDeps> {
40+
function createMockFsDeps(readFileSyncResult?: string | Error): Partial<PlatformFsDeps> {
4141
return {
4242
readFileSync: mock.fn(() => {
4343
if (readFileSyncResult instanceof Error) {
4444
throw readFileSyncResult;
4545
}
4646
return Buffer.from(readFileSyncResult ?? '');
47-
}) as unknown as FsDeps['readFileSync'],
47+
}) as unknown as PlatformPlatformFsDeps['readFileSync'],
4848
};
4949
}
5050

@@ -78,7 +78,7 @@ describe('getPlatformInfo', () => {
7878
const processDeps = createMockProcessDeps({ platform: 'linux', arch: 'x64' });
7979
const fsDeps = createMockFsDeps('NAME="Alpine Linux"\nID=alpine');
8080

81-
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as FsDeps), 'alpine');
81+
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as PlatformFsDeps), 'alpine');
8282
assert.strictEqual(platform.getArch(processDeps), 'x64');
8383
});
8484

@@ -87,29 +87,29 @@ describe('getPlatformInfo', () => {
8787

8888
// First call throws, second returns alpine
8989
let callCount = 0;
90-
const fsDeps: Partial<FsDeps> = {
90+
const fsDeps: Partial<PlatformFsDeps> = {
9191
readFileSync: mock.fn((filePath: string) => {
9292
callCount++;
9393
if (callCount === 1) {
9494
throw new Error('File not found');
9595
}
9696
return Buffer.from('NAME="Alpine Linux"\nID=alpine');
97-
}) as unknown as FsDeps['readFileSync'],
97+
}) as unknown as PlatformPlatformFsDeps['readFileSync'],
9898
};
9999

100-
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as FsDeps), 'alpine');
100+
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as PlatformFsDeps), 'alpine');
101101
assert.strictEqual(platform.getArch(processDeps), 'x64');
102102
});
103103

104104
it('failed to detect alpine', () => {
105105
const processDeps = createMockProcessDeps({ platform: 'linux', arch: 'x64' });
106-
const fsDeps: Partial<FsDeps> = {
106+
const fsDeps: Partial<PlatformFsDeps> = {
107107
readFileSync: mock.fn(() => {
108108
throw new Error('File not found');
109-
}) as unknown as FsDeps['readFileSync'],
109+
}) as unknown as PlatformPlatformFsDeps['readFileSync'],
110110
};
111111

112-
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as FsDeps), 'linux');
112+
assert.strictEqual(platform.getSupportedOS(processDeps, fsDeps as PlatformFsDeps), 'linux');
113113
assert.strictEqual(platform.getArch(processDeps), 'x64');
114114

115115
// Check that warning was logged - the message could be in arguments[0] or arguments[1]

test/unit/process.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@
2020
import { describe, it, mock } from 'node:test';
2121
import assert from 'node:assert';
2222
import { SCANNER_CLI_DEFAULT_BIN_NAME, WINDOWS_WHERE_EXE_PATH } from '../../src/constants';
23-
import { ProcessDeps } from '../../src/deps';
24-
import { locateExecutableFromPath } from '../../src/process';
23+
import { locateExecutableFromPath, ProcessProcessDeps } from '../../src/process';
2524

2625
// Mock console.log to suppress output
2726
mock.method(console, 'log', () => {});
2827

29-
function createMockProcessDeps(overrides: Partial<ProcessDeps> = {}): ProcessDeps {
28+
function createMockProcessDeps(overrides: Partial<ProcessProcessDeps> = {}): ProcessProcessDeps {
3029
return {
3130
platform: 'linux',
3231
arch: 'x64',
33-
env: {},
34-
cwd: () => '/test',
3532
...overrides,
3633
};
3734
}

0 commit comments

Comments
 (0)