Skip to content

Commit

Permalink
add unit test for remote collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed May 17, 2023
1 parent 6ce5d7d commit f3b9910
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions extension/src/setup/collect.test.ts
Original file line number Diff line number Diff line change
@@ -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
})
})
})
4 changes: 2 additions & 2 deletions extension/src/setup/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const collectSectionCollapsed = (
export const collectRemoteList = async (
dvcRoots: string[],
getRemoteList: (cwd: string) => Promise<string | undefined>
): Promise<RemoteList> => {
const acc: { [dvcRoot: string]: { [alias: string]: string } | undefined } = {}
): Promise<NonNullable<RemoteList>> => {
const acc: NonNullable<RemoteList> = {}

for (const dvcRoot of dvcRoots) {
const remoteList = await getRemoteList(dvcRoot)
Expand Down

0 comments on commit f3b9910

Please sign in to comment.