예제 #1
0
        public async Task ValidateStatus()
        {
            int    workflowId     = default;
            string workflowStatus = default;

            try
            {
                workflowId = await _githubApiService.GetWorkflowId();

                _githubActionService.LogDebug($"Workflow Id: {workflowId}");
            }
            catch (Exception)
            {
                _githubActionService.LogFatal($"Unable to find workflow with the name {_settings.Workflow}");
            }

            try
            {
                workflowStatus = await _githubApiService.GetWorkflowStatus(workflowId);

                _githubActionService.LogDebug($"Workflow Status: {workflowStatus}");
            }
            catch (Exception)
            {
                _githubActionService.LogFatal($"Unable to find last workflow run for {_settings.Workflow}");
            }

            if (!string.Equals(workflowStatus, _settings.Status, StringComparison.InvariantCultureIgnoreCase))
            {
                _githubActionService.LogFatal($"Latest workflow run returned a status of {workflowStatus} rather than expected {_settings.Status}");
            }
            _githubActionService.LogDebug($"Latest workflow run returned a status of {workflowStatus}; expected {_settings.Status}");
        }
예제 #2
0
        public void CanLogFatal()
        {
            // test
            _githubActionService.LogFatal("My Test");
            _githubActionService.LogFatal("this should be logged.", "alpha.cs");
            _githubActionService.LogFatal("this should be logged.", "beta.cs", "20");
            _githubActionService.LogFatal("this should be logged.", "cappa.cs", "40", "1");
            _githubActionService.LogFatal("this should be logged.", "delta.cs", null, "10");

            // assertions
            _writeLine.Verify(x => x(It.Is <string>(m => m == "::error ::My Test")), Times.Once);
            _writeLine.Verify(x => x(It.Is <string>(m => m == "::error file=alpha.cs::this should be logged.")), Times.Once);
            _writeLine.Verify(x => x(It.Is <string>(m => m == "::error file=beta.cs,line=20::this should be logged.")), Times.Once);
            _writeLine.Verify(x => x(It.Is <string>(m => m == "::error file=cappa.cs,line=40,col=1::this should be logged.")), Times.Once);
            _writeLine.Verify(x => x(It.Is <string>(m => m == "::error file=delta.cs,col=10::this should be logged.")), Times.Once);
            _numberOfFatalExits.Should().Be(5);
        }