Skip to content

Commit

Permalink
Updating L0 for DotNetCoreCLIV2 task (#10773)
Browse files Browse the repository at this point in the history
* Updating L0

* Removing unnecessary imports

* Review comments
  • Loading branch information
issacnitinmsft committed Jul 9, 2019
1 parent dfe5b1a commit ce203ff
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 10 deletions.
9 changes: 5 additions & 4 deletions Tasks/DotNetCoreCLIV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,15 @@ describe('DotNetCoreExe Suite', function () {


it('publish works with publishWebProjects option if .csproj have Microsoft.Net.Sdk.Web', (done: MochaDone) => {
process.env["__projects__"] = "havesdk*/*.csproj;";
process.env["__publishWebProjects__"] = "true";
let tp = path.join(__dirname, 'publishInputs.js')
process.env["__projects__"] = "validateWebProject.csproj";
process.env["workingDirectory"] = ".";
process.env["__publishWebProject__"] = "true";
let tp = path.join(__dirname, 'validateWebProject.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();

assert(tr.invokedToolCount == 1, 'should have invoked been invoked once');
assert(tr.succeeded, 'task should have failed');
assert(tr.succeeded, 'task should have succeeded');
done();
})

Expand Down
6 changes: 0 additions & 6 deletions Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"code": 1,
"stdout": "not published",
"stderr": ""
},
"dotnet publish havesdk/project.csproj": {
"code": 0,
"stdout": "published",
"stderr": ""
}
},
"findMatch": {
Expand All @@ -103,7 +98,6 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"*fail*/project.json": [],
"*customoutput/project.json": ["web3/project.json", "lib2/project.json"],
"dummy/project.json": ["dummy/project.json"],
"havesdk*/*.csproj": ["havesdk/project.csproj"],
"" : []
}
};
Expand Down
17 changes: 17 additions & 0 deletions Tasks/DotNetCoreCLIV2/Tests/validateWebProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Controllers/ValuesController.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>
42 changes: 42 additions & 0 deletions Tasks/DotNetCoreCLIV2/Tests/validateWebProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import path = require('path');

let taskPath = path.join(__dirname, '..', 'dotnetcore.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('command', "publish");
tmr.setInput('projects', process.env["__projects__"]);
tmr.setInput('publishWebProjects', process.env["__publishWebProjects__"] && process.env["__publishWebProjects__"] == "true" ? "true" : "false");
tmr.setInput('arguments', process.env["__arguments__"] ? process.env["__arguments__"] : "");
tmr.setInput('modifyOutputPath', process.env["modifyOutput"] == "false" ? "false" : "true");
tmr.setInput('zipAfterPublish', process.env["zipAfterPublish"] ? process.env["zipAfterPublish"] : "false");
tmr.setInput('workingDirectory', process.env["workingDirectory"] ? process.env["workingDirectory"] : "");

process.env['TASK_TEST_TRACE'] = "true";

var projectFile = path.join(__dirname, process.env["__projects__"]);
var execCommand = "dotnet publish " + projectFile

let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"which": {
"dotnet": "dotnet",
},
"checkPath": { "dotnet": true },
"exec": {},
"findMatch": {
"**/*.csproj\n**/*.vbproj\n**/*.fsproj": [projectFile]
}
}

a['exec'][execCommand] = {
"code": 0,
"stdout": "published",
"stderr": ""
}

process.env["MOCK_NORMALIZE_SLASHES"] = "true";
tmr.setAnswers(a)
tmr.registerMock('azure-pipelines-task-lib/toolrunner', require('azure-pipelines-task-lib/mock-toolrunner'));

tmr.run();

0 comments on commit ce203ff

Please sign in to comment.