diff --git a/extension/src/setup/collect.test.ts b/extension/src/setup/collect.test.ts new file mode 100644 index 0000000000..8f426d2a4f --- /dev/null +++ b/extension/src/setup/collect.test.ts @@ -0,0 +1,30 @@ +import { collectRemoteList } from './collect' +import { dvcDemoPath } from '../test/util' +import { join } from '../test/util/path' + +describe('collectRemoteList', () => { + it('should return the expected data structure', async () => { + const mockedRoot = join('some', 'other', 'root') + const remoteList = await collectRemoteList( + [dvcDemoPath, 'mockedOtherRoot', mockedRoot], + root => + Promise.resolve( + { + [dvcDemoPath]: + 'storage s3://dvc-public/remote/mnist-vscode\nbackup gdrive://appDataDir\nurl https://remote.dvc.org/mnist-vscode', + mockedOtherRoot: '', + [mockedRoot]: undefined + }[root] + ) + ) + expect(remoteList).toStrictEqual({ + [dvcDemoPath]: { + backup: 'gdrive://appDataDir', + storage: 's3://dvc-public/remote/mnist-vscode', + url: 'https://remote.dvc.org/mnist-vscode' + }, + mockedOtherRoot: undefined, + [mockedRoot]: undefined + }) + }) +}) diff --git a/extension/src/setup/collect.ts b/extension/src/setup/collect.ts index 58b85544bb..cadf226384 100644 --- a/extension/src/setup/collect.ts +++ b/extension/src/setup/collect.ts @@ -25,8 +25,8 @@ export const collectSectionCollapsed = ( export const collectRemoteList = async ( dvcRoots: string[], getRemoteList: (cwd: string) => Promise -): Promise => { - const acc: { [dvcRoot: string]: { [alias: string]: string } | undefined } = {} +): Promise> => { + const acc: NonNullable = {} for (const dvcRoot of dvcRoots) { const remoteList = await getRemoteList(dvcRoot)