From 698447f6365c55b7ac1fde2742db202549101701 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 34edff62..86a1286f 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);