Skip to content

Commit 3781f6a

Browse files
committed
fix: throw in lock test constructor when muxer is null, apply dotnet format
1 parent b791ce4 commit 3781f6a

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

tests/Foundatio.Redis.Tests/Locks/RedisLockTests.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ public RedisLockTests(ITestOutputHelper output) : this(output, null) { }
2525
protected RedisLockTests(ITestOutputHelper output, RedisProtocol? protocol) : base(output)
2626
{
2727
_protocol = protocol;
28-
var muxer = SharedConnection.GetMuxer(Log, _protocol);
29-
if (muxer is null)
30-
{
31-
_cache = null!;
32-
_messageBus = null!;
33-
return;
34-
}
28+
var muxer = SharedConnection.GetMuxer(Log, _protocol)
29+
?? throw new InvalidOperationException("Redis connection is not configured. Set the RedisConnectionString environment variable.");
3530

3631
_cache = new RedisCacheClient(o => o.ConnectionMultiplexer(muxer).LoggerFactory(Log));
3732
_messageBus = new RedisMessageBus(o => o.Subscriber(muxer.GetSubscriber()).Topic(_topic).LoggerFactory(Log));

tests/Foundatio.Redis.Tests/Queues/RedisQueueTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ public async Task VerifyCacheKeysAreCorrect()
268268
using (queue)
269269
{
270270
var muxer = SharedConnection.GetMuxer(Log, Protocol);
271-
if (muxer is null)
272-
return;
271+
if (muxer is null)
272+
return;
273273

274-
var db = muxer.GetDatabase();
275-
string listPrefix = muxer.IsCluster() ? "{q:SimpleWorkItem}" : "q:SimpleWorkItem";
274+
var db = muxer.GetDatabase();
275+
string listPrefix = muxer.IsCluster() ? "{q:SimpleWorkItem}" : "q:SimpleWorkItem";
276276

277-
string? id = await queue.EnqueueAsync(new SimpleWorkItem { Data = "blah", Id = 1 });
278-
Assert.NotNull(id);
279-
Assert.True(await db.KeyExistsAsync($"{listPrefix}:{id}"));
277+
string? id = await queue.EnqueueAsync(new SimpleWorkItem { Data = "blah", Id = 1 });
278+
Assert.NotNull(id);
279+
Assert.True(await db.KeyExistsAsync($"{listPrefix}:{id}"));
280280
Assert.Equal(1, await db.ListLengthAsync($"{listPrefix}:in"));
281281
Assert.True(await db.KeyExistsAsync($"{listPrefix}:{id}:enqueued"));
282282
Assert.Equal(3, await muxer.CountAllKeysAsync());

0 commit comments

Comments
 (0)