Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 870ed3b

Browse files
committed
Fix installer tests
1 parent 7e838a5 commit 870ed3b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/GitHub.Api/Helpers/AssemblyResources.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static NPath ToFile(ResourceType resourceType, string resource, NPath des
3333
if (stream != null)
3434
return destinationPath.Combine(resource).WriteAllBytes(stream.ToByteArray());
3535

36-
return environment.ExtensionInstallPath.Combine(type, os, resource);
36+
return environment.ExtensionInstallPath.Combine(type, os, resource).Copy(destinationPath.Combine(resource));
3737
}
3838
}
3939
}

src/GitHub.Api/Tasks/TaskBase.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public interface ITask : IAsyncResult
5151
bool IsChainExclusive();
5252

5353
void UpdateProgress(long value, long total, string message = null);
54+
ITask GetEndOfChain();
5455
}
5556

5657
public interface ITask<TResult> : ITask
@@ -192,7 +193,7 @@ public virtual T Then<T>(T nextTask, TaskRunOptions runOptions = TaskRunOptions.
192193
// if the current task has a fault handler, attach it to the chain we're appending
193194
if (finallyHandler != null)
194195
{
195-
var endOfChainTask = nextTaskBase.GetBottomMostTask();
196+
TaskBase endOfChainTask = (TaskBase)nextTaskBase.GetEndOfChain();
196197
while (endOfChainTask != this && endOfChainTask != null)
197198
{
198199
endOfChainTask.finallyHandler += finallyHandler;
@@ -373,12 +374,12 @@ protected TaskBase GetTopMostTask()
373374
return depends.GetTopMostTask(null, false);
374375
}
375376

376-
protected TaskBase GetBottomMostTask()
377+
public ITask GetEndOfChain()
377378
{
378379
if (continuationOnSuccess != null)
379-
return continuationOnSuccess.GetBottomMostTask();
380+
return continuationOnSuccess.GetEndOfChain();
380381
else if (continuationOnAlways != null)
381-
return continuationOnAlways.GetBottomMostTask();
382+
return continuationOnAlways.GetEndOfChain();
382383
return this;
383384
}
384385

src/tests/IntegrationTests/Installer/GitInstallerTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ public void GitInstallTest()
5050
TestBasePath.Combine("git").CreateDirectory();
5151

5252
var gitInstaller = new GitInstaller(Environment, CancellationToken.None, installDetails);
53-
53+
var startTask = gitInstaller.SetupGitIfNeeded();
54+
var endTask = new FuncTask<NPath, NPath>(CancellationToken.None, (s, path) => path);
55+
startTask.OnEnd += (thisTask, path, success, exception) => thisTask.GetEndOfChain().Then(endTask);
56+
startTask.Start();
5457
NPath? resultPath = null;
55-
Assert.DoesNotThrow(async () => resultPath = await gitInstaller.SetupGitIfNeeded().Task);
58+
Assert.DoesNotThrow(async () => resultPath = await endTask.Task);
5659
resultPath.Should().NotBeNull();
5760
}
5861
}

0 commit comments

Comments
 (0)