Skip to content

Commit d3e6853

Browse files
authored
Merge pull request #64 from OpenForgeProject/fix-ai-findings
🔧 test: improve user messages in DdevUtils validation tests
2 parents b363950 + d5c8cc3 commit d3e6853

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/test/ddev-utils.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ suite('DdevUtils Test Suite', () => {
118118
spawnSyncStub.onSecondCall().returns({ status: 1, stderr: 'DDEV not running' });
119119

120120
const result = DdevUtils.validateDdevTool('phpstan', '/test/workspace');
121+
const expectedMessage = "DDEV project appears to be stopped. Please start DDEV with 'ddev start' to use phpstan.";
121122

122123
assert.strictEqual(result.isValid, false);
123124
assert.strictEqual(result.errorType, 'ddev-not-running');
124-
assert.ok(result.userMessage && result.userMessage.includes('appears to be stopped'));
125+
assert.strictEqual(result.userMessage, expectedMessage);
125126
});
126127

127128
test('validateDdevTool returns tool not found message when tool is missing', () => {
@@ -133,11 +134,11 @@ suite('DdevUtils Test Suite', () => {
133134
spawnSyncStub.onSecondCall().returns({ status: 0, stdout: 'test\n' });
134135

135136
const result = DdevUtils.validateDdevTool('phpstan', '/test/workspace');
137+
const expectedMessage = 'phpstan is not installed in the DDEV container. Install it with: ddev composer require --dev phpstan/phpstan';
136138

137139
assert.strictEqual(result.isValid, false);
138140
assert.strictEqual(result.errorType, 'tool-not-found');
139-
assert.ok(result.userMessage?.includes('phpstan is not installed'));
140-
assert.ok(result.userMessage?.includes('phpstan/phpstan'));
141+
assert.strictEqual(result.userMessage, expectedMessage);
141142
});
142143

143144
test('execDdev passes args array correctly', () => {
@@ -158,7 +159,7 @@ suite('DdevUtils Test Suite', () => {
158159

159160
assert.throws(() => {
160161
DdevUtils.execDdev(['ls'], '/test/workspace');
161-
}, (err: any) => {
162+
}, (err: { status: number; stderr: string; stdout?: string; command?: string; workspacePath?: string; name?: string }) => {
162163
return err.status === 1 && err.stderr === 'error';
163164
});
164165
});

0 commit comments

Comments
 (0)