forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some more coverage to utils functions (#21026)
- Loading branch information
Showing
5 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { expect } from 'chai'; | ||
import { OSType } from '../../common'; | ||
import { getSearchPathEnvVarNames } from '../../../client/common/utils/exec'; | ||
|
||
suite('Utils for exec - getSearchPathEnvVarNames function', () => { | ||
const testsData = [ | ||
{ os: 'Unknown', expected: ['PATH'] }, | ||
{ os: 'Windows', expected: ['Path', 'PATH'] }, | ||
{ os: 'OSX', expected: ['PATH'] }, | ||
{ os: 'Linux', expected: ['PATH'] }, | ||
]; | ||
|
||
testsData.forEach((testData) => { | ||
test(`getSearchPathEnvVarNames when os is ${testData.os}`, () => { | ||
const pathVariables = getSearchPathEnvVarNames(testData.os as OSType); | ||
|
||
expect(pathVariables).to.deep.equal(testData.expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { expect } from 'chai'; | ||
import { convertFileType } from '../../../client/common/utils/filesystem'; | ||
|
||
class KnowsFileTypeDummyImpl { | ||
private _isFile: boolean; | ||
|
||
private _isDirectory: boolean; | ||
|
||
private _isSymbolicLink: boolean; | ||
|
||
constructor(isFile = false, isDirectory = false, isSymbolicLink = false) { | ||
this._isFile = isFile; | ||
this._isDirectory = isDirectory; | ||
this._isSymbolicLink = isSymbolicLink; | ||
} | ||
|
||
public isFile() { | ||
return this._isFile; | ||
} | ||
|
||
public isDirectory() { | ||
return this._isDirectory; | ||
} | ||
|
||
public isSymbolicLink() { | ||
return this._isSymbolicLink; | ||
} | ||
} | ||
|
||
suite('Utils for filesystem - convertFileType function', () => { | ||
const testsData = [ | ||
{ info: new KnowsFileTypeDummyImpl(true, false, false), kind: 'File', expected: 1 }, | ||
{ info: new KnowsFileTypeDummyImpl(false, true, false), kind: 'Directory', expected: 2 }, | ||
{ info: new KnowsFileTypeDummyImpl(false, false, true), kind: 'Symbolic Link', expected: 64 }, | ||
{ info: new KnowsFileTypeDummyImpl(false, false, false), kind: 'Unknown', expected: 0 }, | ||
]; | ||
|
||
testsData.forEach((testData) => { | ||
test(`convertFileType when info is a ${testData.kind}`, () => { | ||
const fileType = convertFileType(testData.info); | ||
|
||
expect(fileType).equals(testData.expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { expect } from 'chai'; | ||
import { OSType, getOSType } from '../../../client/common/utils/platform'; | ||
|
||
suite('Utils for platform - getOSType function', () => { | ||
const testsData = [ | ||
{ platform: 'linux', expected: OSType.Linux }, | ||
{ platform: 'darwin', expected: OSType.OSX }, | ||
{ platform: 'anunknownplatform', expected: OSType.Unknown }, | ||
{ platform: 'windows', expected: OSType.Windows }, | ||
]; | ||
|
||
testsData.forEach((testData) => { | ||
test(`getOSType when platform is ${testData.platform}`, () => { | ||
const osType = getOSType(testData.platform); | ||
expect(osType).equal(testData.expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters