public async Task JobExtensionBuildStepsList() { using (TestHostContext hc = CreateTestContext()) { var jobExtension = new JobExtension(); jobExtension.Initialize(hc); _actionManager.Setup(x => x.PrepareActionsAsync(It.IsAny <IExecutionContext>(), It.IsAny <IEnumerable <Pipelines.JobStep> >(), It.IsAny <Guid>())) .Returns(Task.FromResult(new PrepareResult(new List <JobExtensionRunner>(), new Dictionary <Guid, IActionRunner>()))); List <IStep> result = await jobExtension.InitializeJob(_jobEc, _message); var trace = hc.GetTrace(); trace.Info(string.Join(", ", result.Select(x => x.DisplayName))); Assert.Equal(5, result.Count); Assert.Equal("action1", result[0].DisplayName); Assert.Equal("action2", result[1].DisplayName); Assert.Equal("action3", result[2].DisplayName); Assert.Equal("action4", result[3].DisplayName); Assert.Equal("action5", result[4].DisplayName); Assert.NotNull(result[0].ExecutionContext); Assert.NotNull(result[1].ExecutionContext); Assert.NotNull(result[2].ExecutionContext); Assert.NotNull(result[3].ExecutionContext); Assert.NotNull(result[4].ExecutionContext); } }
public void DontUploadDiagnosticLogIfEnvironmentVariableMissing() { using (TestHostContext hc = CreateTestContext()) { var jobExtension = new JobExtension(); jobExtension.Initialize(hc); jobExtension.FinalizeJob(_jobEc, _message, DateTime.UtcNow); _diagnosticLogManager.Verify(x => x.UploadDiagnosticLogs( It.IsAny <IExecutionContext>(), It.IsAny <IExecutionContext>(), It.IsAny <Pipelines.AgentJobRequestMessage>(), It.IsAny <DateTime>()), Times.Never); } }
public void EnsureFinalizeJobHandlesNullEnvironment() { using (TestHostContext hc = CreateTestContext()) { var jobExtension = new JobExtension(); jobExtension.Initialize(hc); _message.ActionsEnvironment = null; _jobEc = new Runner.Worker.ExecutionContext { Result = TaskResult.Succeeded }; _jobEc.Initialize(hc); _jobEc.InitializeJob(_message, _tokenSource.Token); jobExtension.FinalizeJob(_jobEc, _message, DateTime.UtcNow); Assert.Equal(TaskResult.Succeeded, _jobEc.Result); } }
public void DontUploadDiagnosticLogIfEnvironmentVariableFalse() { using (TestHostContext hc = CreateTestContext()) { var jobExtension = new JobExtension(); jobExtension.Initialize(hc); _message.Variables[Constants.Variables.Actions.RunnerDebug] = "false"; _jobEc = new Runner.Worker.ExecutionContext(); _jobEc.Initialize(hc); _jobEc.InitializeJob(_message, _tokenSource.Token); jobExtension.FinalizeJob(_jobEc, _message, DateTime.UtcNow); _diagnosticLogManager.Verify(x => x.UploadDiagnosticLogs( It.IsAny <IExecutionContext>(), It.IsAny <IExecutionContext>(), It.IsAny <Pipelines.AgentJobRequestMessage>(), It.IsAny <DateTime>()), Times.Never); } }