-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1271212 refactoring of test utils
- Loading branch information
1 parent
22f5b42
commit 0e842c0
Showing
4 changed files
with
133 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Data; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
public static class DbCommandTestExtensions | ||
{ | ||
internal static IDbDataParameter Add(this IDbCommand command, string name, DbType dbType, object value) | ||
{ | ||
var parameter = command.CreateParameter(); | ||
parameter.ParameterName = name; | ||
parameter.DbType = dbType; | ||
parameter.Value = value; | ||
command.Parameters.Add(parameter); | ||
return parameter; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Data; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
public static class DbConnectionTestExtensions | ||
{ | ||
internal static IDbCommand CreateCommand(this IDbConnection connection, string commandText) | ||
{ | ||
var command = connection.CreateCommand(); | ||
command.Connection = connection; | ||
command.CommandText = commandText; | ||
return command; | ||
} | ||
|
||
internal static int ExecuteNonQuery(this IDbConnection connection, string commandText) | ||
{ | ||
var command = connection.CreateCommand(); | ||
command.Connection = connection; | ||
command.CommandText = commandText; | ||
return command.ExecuteNonQuery(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
public enum SFTableType | ||
{ | ||
Standard, | ||
Hybrid, | ||
Iceberg | ||
} | ||
|
||
static class TableTypeTestExtensions | ||
{ | ||
internal static string TableDDLCreationPrefix(this SFTableType val) => val == SFTableType.Standard ? "" : val.ToString().ToUpper(); | ||
|
||
internal static string TableDDLCreationFlags(this SFTableType val) | ||
{ | ||
if (val != SFTableType.Iceberg) | ||
return ""; | ||
var externalVolume = Environment.GetEnvironmentVariable("ICEBERG_EXTERNAL_VOLUME"); | ||
var catalog = Environment.GetEnvironmentVariable("ICEBERG_CATALOG"); | ||
var baseLocation = Environment.GetEnvironmentVariable("ICEBERG_BASE_LOCATION"); | ||
Assert.IsNotNull(externalVolume, "env ICEBERG_EXTERNAL_VOLUME not set!"); | ||
Assert.IsNotNull(catalog, "env ICEBERG_CATALOG not set!"); | ||
Assert.IsNotNull(baseLocation, "env ICEBERG_BASE_LOCATION not set!"); | ||
return $"EXTERNAL_VOLUME = '{externalVolume}' CATALOG = '{catalog}' BASE_LOCATION = '{baseLocation}'"; | ||
} | ||
} | ||
} |