From 2750d336de26e075a07612dbbe4256a7b3a07a4c Mon Sep 17 00:00:00 2001 From: atakavci Date: Mon, 24 Mar 2025 14:59:03 +0300 Subject: [PATCH 1/2] Fix nested batch issue when initial command is within a pipeline (#402) fix nested batch issue when initial command is within a pipeline --- src/NRedisStack/Pipeline.cs | 1 + tests/NRedisStack.Tests/PipelineTests.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/NRedisStack/Pipeline.cs b/src/NRedisStack/Pipeline.cs index 67f23ff8..3035576b 100644 --- a/src/NRedisStack/Pipeline.cs +++ b/src/NRedisStack/Pipeline.cs @@ -6,6 +6,7 @@ public class Pipeline { public Pipeline(IDatabase db) { + db.SetInfoInPipeline(); _batch = db.CreateBatch(); } diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index cf4826fc..d1f2782a 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -157,4 +157,22 @@ public void TestJsonPipeline() Assert.True(setResponse.Result); Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString()); } + + [SkippableTheory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + [Obsolete] + public async void Issue401_TestPipelineAsInitialCommand(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + + Auxiliary.ResetInfoDefaults(); // demonstrate first connection + var pipeline = new Pipeline(db); + + var setTask = pipeline.Json.SetAsync("json-key", "$", "{}"); + _ = pipeline.Db.KeyExpireAsync(key, TimeSpan.FromSeconds(10)); + + pipeline.Execute(); + + Assert.True(await setTask); + } } \ No newline at end of file From 9da06883ab57f4cb72f76c2c079fcf87d6efe420 Mon Sep 17 00:00:00 2001 From: atakavci Date: Mon, 14 Apr 2025 21:59:27 +0300 Subject: [PATCH 2/2] fix test with compatible test context --- tests/NRedisStack.Tests/PipelineTests.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index d1f2782a..52ec7540 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -158,12 +158,10 @@ public void TestJsonPipeline() Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString()); } - [SkippableTheory] - [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] - [Obsolete] - public async void Issue401_TestPipelineAsInitialCommand(string endpointId) + [SkipIfRedis(Is.OSSCluster)] + public async void Issue401_TestPipelineAsInitialCommand() { - IDatabase db = GetCleanDatabase(endpointId); + IDatabase db = redisFixture.Redis.GetDatabase(); Auxiliary.ResetInfoDefaults(); // demonstrate first connection var pipeline = new Pipeline(db);