Skip to content

Commit 8e54360

Browse files
committed
Switch to using dotenv to get test environment variables
1 parent 66c5485 commit 8e54360

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
"@typescript-eslint/parser": "^7.11.0",
186186
"@vscode/test-cli": "^0.0.9",
187187
"@vscode/test-electron": "^2.4.0",
188+
"dotenv": "^16.4.7",
188189
"esbuild": "^0.24.0",
189190
"eslint": "^8.57.0",
190191
"husky": "^9.1.7",
@@ -196,9 +197,9 @@
196197
},
197198
"dependencies": {
198199
"@anthropic-ai/bedrock-sdk": "^0.10.2",
199-
"@aws-sdk/client-bedrock-runtime": "^3.706.0",
200200
"@anthropic-ai/sdk": "^0.26.0",
201201
"@anthropic-ai/vertex-sdk": "^0.4.1",
202+
"@aws-sdk/client-bedrock-runtime": "^3.706.0",
202203
"@google/generative-ai": "^0.18.0",
203204
"@modelcontextprotocol/sdk": "^1.0.1",
204205
"@types/clone-deep": "^4.0.4",

src/test/extension.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const assert = require('assert');
22
const vscode = require('vscode');
33
const path = require('path');
44
const fs = require('fs');
5+
const dotenv = require('dotenv');
6+
7+
// Load test environment variables
8+
const testEnvPath = path.join(__dirname, '.test_env');
9+
dotenv.config({ path: testEnvPath });
510

611
suite('Roo Cline Extension Test Suite', () => {
712
vscode.window.showInformationMessage('Starting Roo Cline extension tests.');
@@ -34,14 +39,11 @@ suite('Roo Cline Extension Test Suite', () => {
3439
}
3540

3641
// Verify API key is set and valid
37-
const testEnvPath = path.join(__dirname, '.test_env');
38-
const envContent = fs.readFileSync(testEnvPath, 'utf8');
39-
const match = envContent.match(/OPEN_ROUTER_API_KEY=(.+)/);
40-
if (!match) {
41-
done(new Error('OpenRouter API key should be present in .test_env'));
42+
const apiKey = process.env.OPEN_ROUTER_API_KEY;
43+
if (!apiKey) {
44+
done(new Error('OPEN_ROUTER_API_KEY environment variable is not set'));
4245
return;
4346
}
44-
const apiKey = match[1];
4547
if (!apiKey.startsWith('sk-or-v1-')) {
4648
done(new Error('OpenRouter API key should have correct format'));
4749
return;
@@ -180,14 +182,12 @@ suite('Roo Cline Extension Test Suite', () => {
180182
// Set up API configuration
181183
await provider.updateGlobalState('apiProvider', 'openrouter');
182184
await provider.updateGlobalState('openRouterModelId', 'anthropic/claude-3.5-sonnet');
183-
const testEnvPath = path.join(__dirname, '.test_env');
184-
const envContent = fs.readFileSync(testEnvPath, 'utf8');
185-
const match = envContent.match(/OPEN_ROUTER_API_KEY=(.+)/);
186-
if (!match) {
187-
assert.fail('OpenRouter API key should be present in .test_env');
185+
const apiKey = process.env.OPEN_ROUTER_API_KEY;
186+
if (!apiKey) {
187+
assert.fail('OPEN_ROUTER_API_KEY environment variable is not set');
188188
return;
189189
}
190-
await provider.storeSecret('openRouterApiKey', match[1]);
190+
await provider.storeSecret('openRouterApiKey', apiKey);
191191

192192
// Create webview panel with development options
193193
const extensionUri = extension.extensionUri;

0 commit comments

Comments
 (0)