Skip to content

Commit

Permalink
SNOW-950923 Review and github actions improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mhofman committed Jan 12, 2024
1 parent 4aae56e commit 52fcfaf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
61 changes: 31 additions & 30 deletions Snowflake.Data.Tests/IntegrationTests/SFPutGetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ public void TestPutFileProvidesQueryIdOnFailure()
using (var conn = new SnowflakeDbConnection(ConnectionString))
{
conn.Open();
var queryId = PutFile(conn);

var snowflakeDbException = Assert.Throws<SnowflakeDbException>(()=>PutFile(conn));
var queryId = snowflakeDbException.QueryId;

// Assert
Assert.IsNotNull(queryId);
Assert.IsNotEmpty(queryId);
Assert.DoesNotThrow(()=>Guid.Parse(queryId));
}
}
Expand Down Expand Up @@ -514,42 +515,42 @@ string PutFile(
$"PUT file://{t_inputFilePath} {t_internalStagePath}" +
$" AUTO_COMPRESS={(t_autoCompress ? "TRUE" : "FALSE")}" +
$" {additionalAttribute}";

// Upload file
command.CommandText = putQuery;
var reader = command.ExecuteReader();
try
{
var reader = command.ExecuteReader();
Assert.IsTrue(reader.Read());
// Checking query id when reader succeeded
queryId = ((SnowflakeDbDataReader)reader).GetQueryId();
// Checking if query Id is provided on the command level as well
Assert.AreEqual(queryId, ((SnowflakeDbCommand)command).GetQueryId());
// Check file status
Assert.AreEqual(expectedStatus.ToString(),
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.ResultStatus));
// Check source and destination compression type
if (t_autoCompress)
{
Assert.AreEqual(t_sourceCompressionType,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.SourceCompressionType));
Assert.AreEqual(t_destCompressionType,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.DestinationCompressionType));
}
else
{
Assert.AreEqual(SFFileCompressionTypes.NONE.Name,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.SourceCompressionType));
Assert.AreEqual(SFFileCompressionTypes.NONE.Name,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.DestinationCompressionType));
}
Assert.IsNull(reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.ErrorDetails));
}
catch (SnowflakeDbException e)
{
queryId = e.QueryId;
Assert.AreEqual(queryId, ((SnowflakeDbCommand)command).GetQueryId());
// to make sure in a failure case command was set properly with a failed QueryId
Assert.AreEqual(e.QueryId, ((SnowflakeDbCommand)command).GetQueryId());
throw;
}
// Checking query id when reader succeeded
queryId = ((SnowflakeDbDataReader)reader).GetQueryId();
// Checking if query Id is provided on the command level as well
Assert.AreEqual(queryId, ((SnowflakeDbCommand)command).GetQueryId());
// Check file status
Assert.AreEqual(expectedStatus.ToString(),
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.ResultStatus));
// Check source and destination compression type
if (t_autoCompress)
{
Assert.AreEqual(t_sourceCompressionType,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.SourceCompressionType));
Assert.AreEqual(t_destCompressionType,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.DestinationCompressionType));
}
else
{
Assert.AreEqual(SFFileCompressionTypes.NONE.Name,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.SourceCompressionType));
Assert.AreEqual(SFFileCompressionTypes.NONE.Name,
reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.DestinationCompressionType));
}
Assert.IsNull(reader.GetString((int)SFResultSet.PutGetResponseRowTypeInfo.ErrorDetails));
}
return queryId;
}
Expand Down
4 changes: 2 additions & 2 deletions Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SFFileTransferAgentTest : SFBaseTest
const string FileContent = "FTAFileContent";

[SetUp]
public void BeforeTest()
public void BeforeEachTest()
{
// Base object's names on worker thread id
var threadSuffix = TestContext.CurrentContext.WorkerId?.Replace('#', '_');
Expand Down Expand Up @@ -121,7 +121,7 @@ public void BeforeTest()
}

[TearDown]
public void AfterTest()
public void AfterEachTest()
{
// Delete stage directory recursively
if (Directory.Exists(t_locationStage))
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Client/SnowflakeDbException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class SnowflakeDbException : DbException
static private ResourceManager rm = new ResourceManager("Snowflake.Data.Core.ErrorMessages",
typeof(SnowflakeDbException).Assembly);

public string SqlState { get; private set; }
public new string SqlState { get; private set; }

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AWS)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AWS)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, GCP)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, GCP)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AZURE)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

Check warning on line 26 in Snowflake.Data/Client/SnowflakeDbException.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AZURE)

The member 'SnowflakeDbException.SqlState' does not hide an accessible member. The new keyword is not required.

private int VendorCode;

Expand Down

0 comments on commit 52fcfaf

Please sign in to comment.