Skip to content

Commit 9fbdb5d

Browse files
committed
Update single test to turn off Transaction Enlistment as when the code under test is ran now depends on this being off
1 parent 5904dd3 commit 9fbdb5d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/Hangfire.PostgreSql.Tests/PostgreSqlStorageFacts.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@ public PostgreSqlStorageFacts()
1818
_options = new PostgreSqlStorageOptions { PrepareSchemaIfNecessary = false, EnableTransactionScopeEnlistment = true };
1919
}
2020

21+
/// <summary>
22+
/// Ideally we could enforce UTC time-zone for all connections to Hangfire Postgres (to ensure proper DateTime handling) however if the connection is being enlisted
23+
/// then we cannot touch the ConnectionString in any way because otherwise this creates a new prepared transaction, which becomes aborted
24+
///
25+
/// The best we can do at the moment is enforce UTC on connections initialized (and not enlisted) by Hangfire Postgres
26+
/// </summary>
2127
[Fact]
22-
public void Connection_Timezone_Is_Set_To_UTC_For_Npgsql6_Compatibility()
28+
public void Connection_Timezone_Is_Set_To_UTC_For_Npgsql6_Compatibility_When_Enlistment_Not_Set()
2329
{
24-
PostgreSqlStorage storage = CreateStorage();
30+
// Arrange
31+
32+
// Turn off transaction enlistment for this test
33+
// We won't be performing any queries so there is no side-effect for having this disabled
34+
_options.EnableTransactionScopeEnlistment = false;
2535

36+
PostgreSqlStorage storage = CreateStorage();
37+
38+
// Act
2639
using (var connection = storage.CreateAndOpenConnection())
2740
{
41+
// Assert
2842
Assert.Equal("UTC", connection.Timezone);
2943
}
3044
}

0 commit comments

Comments
 (0)