From bcce8ef8e67730c0958a3cae0cb567b1160ba354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Hofman?= Date: Thu, 9 May 2024 20:04:38 +0200 Subject: [PATCH] SNOW-937188 added test to cover pool retrieval not working for invalid connection string --- .../UnitTests/Session/SessionPoolTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Snowflake.Data.Tests/UnitTests/Session/SessionPoolTest.cs b/Snowflake.Data.Tests/UnitTests/Session/SessionPoolTest.cs index 3d35f74d0..95b4e596e 100644 --- a/Snowflake.Data.Tests/UnitTests/Session/SessionPoolTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Session/SessionPoolTest.cs @@ -1,7 +1,10 @@ using System.Net; using System.Text.RegularExpressions; using NUnit.Framework; +using Snowflake.Data.Client; +using Snowflake.Data.Core; using Snowflake.Data.Core.Session; +using Snowflake.Data.Tests.Util; namespace Snowflake.Data.Tests.UnitTests.Session { @@ -86,6 +89,20 @@ public void TestPoolIdentificationBasedOnConnectionString(string connectionStrin Assert.AreEqual(expectedPoolIdentification, poolIdentification); } + [Test] + public void TestRetrievePoolFailureForInvalidConnectionString() + { + // arrange + var invalidConnectionString = "account=someAccount;db=someDb;host=someHost;user=SomeUser;port=443"; // invalid because password is not provided + + // act + var exception = Assert.Throws(() => SessionPool.CreateSessionPool(invalidConnectionString, null)); + + // assert + SnowflakeDbExceptionAssert.HasErrorCode(exception, SFError.MISSING_CONNECTION_PROPERTY); + Assert.IsTrue(exception.Message.Contains("Required property PASSWORD is not provided")); + } + [Test] public void TestPoolIdentificationBasedOnInternalId() {