Skip to content

Commit 1b08e1b

Browse files
authored
Fix force test regex (#4214)
1 parent 4a73f54 commit 1b08e1b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

extension/src/cli/dvc/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const Prompt = {
2-
TRY_FORCE: /Use\s['`]-f.*?['`]\sto\sforce\./
2+
TRY_FORCE: /Use\s['`](-f|--force).*?['`]\sto\sforce\./
33
} as const

extension/src/repository/commands/index.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,28 @@ describe('getResourceCommand', () => {
8282
expect(mockedFunc).toHaveBeenCalledTimes(1)
8383
})
8484

85-
it('should return a function that calls warnOfConsequences if the first function fails with a force prompt', async () => {
86-
const stderr = `I deed, but ${TRY_FORCE}`
85+
it('should return a function that calls warnOfConsequences if the first function fails with a -f prompt', async () => {
86+
const stderr = 'I deed. Use `-f` to force.'
87+
const userCancelled = undefined
88+
mockedFunc.mockRejectedValueOnce({ stderr })
89+
mockedGetWarningResponse.mockResolvedValueOnce(userCancelled)
90+
91+
const commandToRegister = getResourceCommand(
92+
mockedInternalCommands,
93+
mockedCommandId
94+
)
95+
96+
const undef = await commandToRegister({
97+
dvcRoot: mockedDvcRoot,
98+
resourceUri: { fsPath: mockedTarget } as Uri
99+
})
100+
101+
expect(undef).toStrictEqual(userCancelled)
102+
expect(mockedFunc).toHaveBeenCalledTimes(1)
103+
})
104+
105+
it('should return a function that calls warnOfConsequences if the first function fails with a --force prompt', async () => {
106+
const stderr = 'I deed, but Use `--force` to force.'
87107
const userCancelled = undefined
88108
mockedFunc.mockRejectedValueOnce({ stderr })
89109
mockedGetWarningResponse.mockResolvedValueOnce(userCancelled)

0 commit comments

Comments
 (0)