-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing mock-fs; fixing deps; fixing manifest
- Loading branch information
1 parent
8068b95
commit 14816af
Showing
59 changed files
with
815 additions
and
5,916 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,7 @@ ModelManifest.xml | |
|
||
Tasks/**/*.js | ||
test/**/*.js | ||
test/**/working | ||
|
||
coverage | ||
test/instrumented | ||
|
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,61 +1,66 @@ | ||
import ma = require('vsts-task-lib/mock-answer'); | ||
import tmrm = require('vsts-task-lib/mock-run'); | ||
import path = require('path'); | ||
import fse = require('fs-extra'); | ||
import mockfs = require('mock-fs'); | ||
import fs = require('fs'); | ||
|
||
let rootDir = path.join(__dirname, '..', 'instrumented'); | ||
let taskPath = path.join(rootDir, 'replaceTokens.js'); | ||
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); | ||
|
||
// set up a tmp file for the test | ||
var workingFolder = path.join(__dirname, "working"); | ||
if (!fs.existsSync(workingFolder)) { | ||
fs.mkdirSync(workingFolder); | ||
} | ||
var tmpFile = path.join(workingFolder, "appsettings.config"); | ||
|
||
// provide answers for task mock | ||
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{ | ||
"checkPath": { | ||
"working": true | ||
}, | ||
"glob": { | ||
"working\\*.config" : [ path.join("working", "file.config") ] | ||
"find": { | ||
"working\\*.config" : [ tmpFile ] | ||
} | ||
}; | ||
tmr.setAnswers(a); | ||
|
||
// mock the fs | ||
let _mockfs = mockfs.fs({ | ||
"working/file.config": ` | ||
fs.writeFile(tmpFile, ` | ||
<configuration> | ||
<appSettings> | ||
<add key="AtSym" value="@@CUSTOM_BUILDMAJORNUM@@.@@CUSTOM_BUILDMINORNUM@@.@@CUSTOM_BUILDPATCHNUM@@" /> | ||
</appSettings> | ||
</configuration> | ||
`}); | ||
tmr.registerMock('fs', _mockfs); | ||
`, | ||
(err) => { | ||
|
||
// set inputs | ||
tmr.setInput('sourcePath', "working"); | ||
tmr.setInput('filePattern', '*.config'); | ||
tmr.setInput('tokenRegex', '@@(\\w+)@@'); | ||
// set inputs | ||
tmr.setInput('sourcePath', "working"); | ||
tmr.setInput('filePattern', '*.config'); | ||
tmr.setInput('tokenRegex', '@@(\\w+)@@'); | ||
|
||
// set variables | ||
process.env["CUSTOM_BUILDMAJORNUM"] = "1"; | ||
process.env["CUSTOM_BUILDMINORNUM"] = "2"; | ||
process.env["CUSTOM_BUILDPATCHNUM"] = "3"; | ||
// set variables | ||
process.env["CUSTOM_BUILDMAJORNUM"] = "1"; | ||
process.env["CUSTOM_BUILDMINORNUM"] = "2"; | ||
process.env["CUSTOM_BUILDPATCHNUM"] = "3"; | ||
|
||
tmr.run(); | ||
tmr.run(); | ||
|
||
// validate the replacement | ||
let actual = (<any>_mockfs).readFileSync('working/file.config', 'utf-8'); | ||
// validate the replacement | ||
let actual = fs.readFileSync(tmpFile, 'utf-8'); | ||
|
||
var expected = ` | ||
var expected = ` | ||
<configuration> | ||
<appSettings> | ||
<add key="AtSym" value="1.2.3" /> | ||
</appSettings> | ||
</configuration> | ||
`; | ||
|
||
if (actual !== expected) { | ||
console.log(actual); | ||
console.error("Replacement failed."); | ||
} else { | ||
console.log("Replacement succeeded!") | ||
} | ||
`; | ||
|
||
if (actual.trim() !== expected.trim()) { | ||
console.log(actual); | ||
console.error("Replacement failed."); | ||
} else { | ||
console.log("Replacement succeeded!") | ||
} | ||
}); |
Oops, something went wrong.