Skip to content

Commit e750707

Browse files
committed
Add the tests of the Setup class
1 parent 8b34f06 commit e750707

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

src/Cmdlets/Install-Release.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public class InstallReleaseCommand: PSCmdlet {
3030
/// </summary>
3131
protected override void ProcessRecord() {
3232
var release = ParameterSetName == "InputObject" ? InputObject : new Release(Version);
33-
// TODO WriteObject(new Setup(release).Install(OptionalTasks));
33+
WriteObject(new Setup(release).Install(OptionalTasks).GetAwaiter().GetResult());
3434
}
3535
}

test/Setup.Tests.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ namespace Belin.SetupAnt;
77
[TestClass]
88
public sealed class SetupTests(TestContext testContext) {
99

10+
[ClassInitialize]
11+
public static void ClassInitialize(TestContext testContext) {
12+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ENV"))) Environment.SetEnvironmentVariable("GITHUB_ENV", "var/GitHub-Env.txt");
13+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_PATH"))) Environment.SetEnvironmentVariable("GITHUB_PATH", "var/GitHub-Path.txt");
14+
}
15+
1016
[TestMethod]
11-
public void Download() {
17+
public async Task Download() {
18+
var path = await new Setup(Release.Latest).Download(optionalTasks: true, testContext.CancellationToken);
19+
IsTrue(File.Exists(Path.Join(path, "bin", OperatingSystem.IsWindows() ? "ant.cmd" : "ant")));
20+
21+
var jars = Directory.EnumerateFiles(Path.Join(path, "lib"), "*.jar");
22+
HasCount(1, jars.Where(jar => Path.GetFileName(jar).StartsWith("ivy-")));
1223
}
1324

1425
[TestMethod]
15-
public void Install() {
26+
public async Task Install() {
27+
var path = await new Setup(Release.Latest).Install(optionalTasks: false, testContext.CancellationToken);
28+
AreEqual(path, Environment.GetEnvironmentVariable("ANT_HOME"));
29+
Contains(path, Environment.GetEnvironmentVariable("PATH")!);
1630
}
1731
}

test/SetupTests.ps1

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)