Skip to content

Commit 46a83ea

Browse files
deep.equal asserts
1 parent e8179ca commit 46a83ea

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

src/test/unittest/configuration/dynamicdebugConfigurationService.unit.test.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { expect } from 'chai';
77
import * as path from 'path';
88
import * as sinon from 'sinon';
99
import { Uri, WorkspaceFolder } from 'vscode';
10+
import { DebuggerTypeName } from '../../../extension/constants';
1011
import { DynamicPythonDebugConfigurationService } from '../../../extension/debugger/configuration/dynamicdebugConfigurationService';
1112
import * as configurationUtils from '../../../extension/debugger/configuration/utils/configuration';
1213

@@ -31,6 +32,15 @@ suite('Debugging - Dynamic Debug Configuration Service', () => {
3132
return (result ?? []).filter((c) => c.name?.includes('FastAPI'));
3233
};
3334

35+
const fileVariantConfig = {
36+
name: 'Python Debugger: FastAPI File',
37+
type: DebuggerTypeName,
38+
request: 'launch',
39+
module: 'fastapi',
40+
args: ['run', '${file}'],
41+
jinja: true,
42+
};
43+
3444
test('No FastAPI detected → no FastAPI configs offered', async () => {
3545
getFastApiPathsStub.resolves([]);
3646

@@ -43,23 +53,46 @@ suite('Debugging - Dynamic Debug Configuration Service', () => {
4353

4454
const fastApi = await fastApiProviders();
4555
expect(fastApi).to.have.length(2);
46-
expect(fastApi[0]).to.include({ name: 'Python Debugger: FastAPI', module: 'fastapi' });
47-
expect(fastApi[0].args).to.deep.equal(['run', 'main.py']);
48-
expect(fastApi[1]).to.include({ name: 'Python Debugger: FastAPI File', module: 'fastapi' });
49-
expect(fastApi[1].args).to.deep.equal(['run', '${file}']);
56+
expect(fastApi[0]).to.deep.equal({
57+
name: 'Python Debugger: FastAPI',
58+
type: DebuggerTypeName,
59+
request: 'launch',
60+
module: 'fastapi',
61+
args: ['run', 'main.py'],
62+
jinja: true,
63+
});
64+
expect(fastApi[1]).to.deep.equal(fileVariantConfig);
5065
});
5166

5267
test('Single match in subdirectory → project config passes path explicitly', async () => {
5368
getFastApiPathsStub.resolves([Uri.file('/work/backend/app/main.py')]);
5469

5570
const fastApi = await fastApiProviders();
56-
expect(fastApi[0].args).to.deep.equal(['run', path.join('backend', 'app', 'main.py')]);
71+
expect(fastApi).to.have.length(2);
72+
expect(fastApi[0]).to.deep.equal({
73+
name: 'Python Debugger: FastAPI',
74+
type: DebuggerTypeName,
75+
request: 'launch',
76+
module: 'fastapi',
77+
args: ['run', path.join('backend', 'app', 'main.py')],
78+
jinja: true,
79+
});
80+
expect(fastApi[1]).to.deep.equal(fileVariantConfig);
5781
});
5882

5983
test('Multiple matches → project config falls back to plain `fastapi run`', async () => {
6084
getFastApiPathsStub.resolves([Uri.file('/work/svc-a/main.py'), Uri.file('/work/svc-b/main.py')]);
6185

6286
const fastApi = await fastApiProviders();
63-
expect(fastApi[0].args).to.deep.equal(['run']);
87+
expect(fastApi).to.have.length(2);
88+
expect(fastApi[0]).to.deep.equal({
89+
name: 'Python Debugger: FastAPI',
90+
type: DebuggerTypeName,
91+
request: 'launch',
92+
module: 'fastapi',
93+
args: ['run'],
94+
jinja: true,
95+
});
96+
expect(fastApi[1]).to.deep.equal(fileVariantConfig);
6497
});
6598
});

0 commit comments

Comments
 (0)