Skip to content

Commit

Permalink
Sussing out failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
sburmanoctopus committed Dec 14, 2023
1 parent ef2570a commit 34289eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
using CliWrap;
using CliWrap.Exceptions;
using FluentAssertions;
using FluentAssertions.Execution;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Octopus.Tentacle.Startup;
using Octopus.Tentacle.Tests.Integration.Support;
using Octopus.Tentacle.Tests.Integration.Support.TestAttributes;
using Octopus.Tentacle.Util;
Expand Down Expand Up @@ -332,7 +334,8 @@ public async Task InvalidInstance(TentacleConfigurationTestCase tc)
{
var (exitCode, stdout, stderr) = await RunCommand(tc, "show-thumbprint", "--instance=invalidinstance");

exitCode.Should().Be(1, $"the exit code should be 1 if the instance is not able to be resolved");
using var s = new AssertionScope();
exitCode.Should().Be((int)OctopusProgram.ExitCode.ControlledFailureException, "the exit code should be 1 if the instance is not able to be resolved");
stderr.Should().ContainEquivalentOf("Instance invalidinstance of tentacle has not been configured", "the error message should make it clear the instance has not been configured");
stderr.Should().ContainEquivalentOf("Available instances:", "should provide a hint as to which instances are available on the machine");
stdout.Should().BeNullOrEmpty();
Expand Down
6 changes: 6 additions & 0 deletions source/Octopus.Tentacle/Startup/OctopusProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,32 @@ public int Run()
RunHost(host);
// If we make it to here we can set the error code as either an UnknownCommand for which you got some help, or Success!
exitCode = (int)(commandFromCommandLine == null ? ExitCode.UnknownCommand : ExitCode.Success);
log.Error($"** Finished normally {exitCode}");
}
catch (DependencyResolutionException ex) when (ex.InnerException is ControlledFailureException)
{
exitCode = HandleException((ControlledFailureException)ex.InnerException);
log.Error($"** Finished DependencyResolutionException {exitCode}");
}
catch (ControlledFailureException ex)
{
exitCode = HandleException(ex);
log.Error($"** Finished ControlledFailureException {exitCode}");
}
catch (SecurityException ex)
{
exitCode = HandleException(ex);
log.Error($"** Finished SecurityException {exitCode}");
}
catch (ReflectionTypeLoadException ex)
{
exitCode = HandleException(ex);
log.Error($"** Finished ReflectionTypeLoadException {exitCode}");
}
catch (Exception ex)
{
exitCode = HandleException(ex);
log.Error($"** Finished Exception {exitCode}");
}

host?.OnExit(exitCode);
Expand Down

0 comments on commit 34289eb

Please sign in to comment.