From f70802100cb314a88bcb0345936aae130cdad950 Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-lf Date: Tue, 23 Jan 2024 19:14:32 -0800 Subject: [PATCH] SNOW-990111: Modify config finder tests --- .../EasyLoggingConfigFinderTest.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs b/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs index 2b32b6bd5..1d0a1162a 100644 --- a/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs @@ -120,7 +120,6 @@ public void TestThatTakesFilePathFromHomeDirectoryWhenNoOtherWaysPossible() } [Test] - [Ignore("TODO: modify the test and remove Ignore")] public void TestThatConfigFileIsNotUsedIfOthersCanModifyTheConfigFile() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) @@ -130,6 +129,8 @@ public void TestThatConfigFileIsNotUsedIfOthersCanModifyTheConfigFile() // arrange var configFilePath = CreateConfigTempFile(Config(EasyLoggingLogLevel.Warn.ToString(), InputConfigFilePath)); + var fileInfo = new Mono.Unix.UnixFileInfo(InputConfigFilePath); + fileInfo.Create(Mono.Unix.FileAccessPermissions.AllPermissions); // act var thrown = Assert.Throws(() => t_finder.FindConfigFilePath(configFilePath)); @@ -166,6 +167,20 @@ public void TestThatDoesNotFailWhenSearchForOneOfDirectoriesFails() t_environmentOperations.Verify(e => e.GetFolderPath(Environment.SpecialFolder.UserProfile), Times.Once); } + [Test] + public void TestThatDoesNotFailWhenHomeDirectoryReturnsNull() + { + // arrange + MockHomeDirectoryReturnsNull(); + + // act + var filePath = t_finder.FindConfigFilePath(null); + + // assert + Assert.IsNull(filePath); + t_environmentOperations.Verify(e => e.GetFolderPath(Environment.SpecialFolder.UserProfile), Times.Once); + } + [Test] public void TestThatDoesNotFailWhenHomeDirectoryDoesNotExist() {