From fdd6641a6b9957125b2c60c5f2327ec639f29308 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Mon, 26 Aug 2024 08:45:09 +0700 Subject: [PATCH] Only print Mongo container ID if it exists --- src/LfMerge.Core.Tests/SRTestEnvironment.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/LfMerge.Core.Tests/SRTestEnvironment.cs b/src/LfMerge.Core.Tests/SRTestEnvironment.cs index a344a255..682af308 100644 --- a/src/LfMerge.Core.Tests/SRTestEnvironment.cs +++ b/src/LfMerge.Core.Tests/SRTestEnvironment.cs @@ -97,9 +97,11 @@ protected override void Dispose(bool disposing) if (CleanUpTestData) { StopMongo(); } else { - Console.WriteLine($"Leaving Mongo container {MongoContainerId} around to examine data on failed test."); - Console.WriteLine($"It is listening on {Settings.MongoDbHostNameAndPort}"); - Console.WriteLine($"To delete it, run `docker stop {MongoContainerId} ; docker rm {MongoContainerId}`."); + if (MongoContainerId is not null) { + Console.WriteLine($"Leaving Mongo container {MongoContainerId} around to examine data on failed test."); + Console.WriteLine($"It is listening on {Settings.MongoDbHostNameAndPort}"); + Console.WriteLine($"To delete it, run `docker stop {MongoContainerId} ; docker rm {MongoContainerId}`."); + } } } base.Dispose(disposing);