Skip to content

Commit

Permalink
fix cross platform test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Jan 31, 2023
1 parent f1092eb commit 8f02ff4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion languageServer/src/LanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class LanguageServer {

if (locationsAccumulator.length === 0) {
for (const possibleFile of symbolUnderCursor.name.split(' ')) {
const possiblePath = join(dirname(document.uri), possibleFile)
const possiblePath = URI.parse(
join(dirname(document.uri), possibleFile)
).toString()
const file = await connection.sendRequest<{
contents: string
} | null>('readFileContents', possiblePath)
Expand Down
9 changes: 6 additions & 3 deletions languageServer/src/test/definitions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Position, Range } from 'vscode-languageserver/node'
import { URI } from 'vscode-uri'
import { params_dvc_yaml, train_dvc_yaml } from './fixtures/examples/valid'
import { params } from './fixtures/params'
import { train } from './fixtures/python'
Expand Down Expand Up @@ -58,8 +59,10 @@ describe('textDocument/definitions', () => {
})

it('should try to read the file system when a python file is unknown', async () => {
const trainUri = URI.file('train.py').toString()

mockedReadFileContents.mockImplementation(path => {
if (path === 'file:/train.py') {
if (path === trainUri) {
return { contents: train }
}
return null
Expand All @@ -75,14 +78,14 @@ describe('textDocument/definitions', () => {

const response = await requestDefinitions(dvcYaml, 'train.py')

expect(mockedReadFileContents).toHaveBeenCalledWith('file:/train.py', {
expect(mockedReadFileContents).toHaveBeenCalledWith(trainUri, {
_isCancelled: false
})

expect(response).toBeTruthy()
expect(response).toStrictEqual({
range: Range.create(Position.create(0, 0), Position.create(7, 13)),
uri: 'file:/train.py'
uri: trainUri
})
})
})

0 comments on commit 8f02ff4

Please sign in to comment.