Skip to content

Commit 83668c4

Browse files
committed
create extensionApiMock file, containing methods returning mocked data for temporary testing purposes.
1 parent d51be9f commit 83668c4

File tree

3 files changed

+577
-8
lines changed

3 files changed

+577
-8
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
"title": "Show extension output",
113113
"category": "Redis for VS Code",
114114
"icon": "$(add)"
115+
},
116+
{
117+
"command": "RedisForVSCode.getAllDatabases",
118+
"title": "Get All Redis Databases",
119+
"category": "Redis for VS Code",
120+
"icon": "$(add)"
115121
}
116122
],
117123
"menus": {

src/extension.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getTitleForKey, handleMessage } from './utils'
1111
import { ViewId } from './constants'
1212
import { logger } from './logger'
1313
import { registerUriHandler } from './utils/handleUri'
14-
import * as extensionApi from './extensionApi'
14+
import * as extensionApiMock from './extensionApiMock'
1515

1616
dotenv.config({ path: path.join(__dirname, '..', '.env') })
1717

@@ -217,24 +217,32 @@ export async function activate(context: vscode.ExtensionContext) {
217217
vscode.commands.registerCommand('RedisForVSCode.refreshDatabases', () => {
218218
sidebarProvider.view?.webview.postMessage({ action: 'RefreshTree' })
219219
}),
220+
221+
// TODO [DA]: Remove, added for testing purposes
222+
vscode.commands.registerCommand('RedisForVSCode.getAllDatabases', async () => {
223+
const dbs = await extensionApiMock.getAllDatabases()
224+
vscode.window.showInformationMessage(
225+
`Found ${dbs.length} database(s).: ${dbs.map((db) => db.name).join(', ')}`,
226+
)
227+
}),
220228
)
221229

222230
registerUriHandler()
223231

224232
// Return the extension API to expose functionalities to the outer world
225233
return {
226234
// Core database operations
227-
getAllDatabases: extensionApi.getAllDatabases,
228-
getDatabaseById: extensionApi.getDatabaseById,
235+
getAllDatabases: extensionApiMock.getAllDatabases,
236+
getDatabaseById: extensionApiMock.getDatabaseById,
229237

230238
// Index operations
231-
getIndexDefinition: extensionApi.getIndexDefinition,
232-
getAllIndexes: extensionApi.getAllIndexes,
233-
hasRedisSearchModule: extensionApi.hasRedisSearchModule,
239+
getIndexDefinition: extensionApiMock.getIndexDefinition,
240+
getAllIndexes: extensionApiMock.getAllIndexes,
241+
hasRedisSearchModule: extensionApiMock.hasRedisSearchModule,
234242

235243
// CLI operations
236-
openCliForDatabase: extensionApi.openCliForDatabase,
237-
executeRedisCommand: extensionApi.executeRedisCommand,
244+
openCliForDatabase: extensionApiMock.openCliForDatabase,
245+
executeRedisCommand: extensionApiMock.executeRedisCommand,
238246
}
239247
}
240248

0 commit comments

Comments
 (0)