From 8769310fdffa560ddf0a57f0d3c5c5d84a137b15 Mon Sep 17 00:00:00 2001 From: atakavci Date: Mon, 27 Jan 2025 16:16:42 +0300 Subject: [PATCH 1/2] changing behaviours in CE 8.0 --- tests/NRedisStack.Tests/Search/SearchTests.cs | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 4dcd036a..8651cebe 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -652,9 +652,6 @@ public void CreateWithFieldNames(string endpointId) SearchResult noFilters = ft.Search(index, new Query()); Assert.Equal(5, noFilters.TotalResults); - SearchResult asOriginal = ft.Search(index, new Query("@first:Jo*")); - Assert.Equal(0, asOriginal.TotalResults); - SearchResult asAttribute = ft.Search(index, new Query("@given:Jo*")); Assert.Equal(2, asAttribute.TotalResults); @@ -662,6 +659,21 @@ public void CreateWithFieldNames(string endpointId) Assert.Equal(1, nonAttribute.TotalResults); } + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void FailWhenAttributeNotExist(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + var ft = db.FT(); + Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) + .AddField(new TextField(FieldName.Of("last"))); + + Assert.True(ft.Create(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc)); + + SearchResult asOriginal = ft.Search(index, new Query("@first:Jo*")); + Assert.Equal(0, asOriginal.TotalResults); + } + [SkippableTheory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public async Task CreateWithFieldNamesAsync(string endpointId) @@ -684,9 +696,6 @@ public async Task CreateWithFieldNamesAsync(string endpointId) SearchResult noFilters = await ft.SearchAsync(index, new Query()); Assert.Equal(5, noFilters.TotalResults); - SearchResult asOriginal = await ft.SearchAsync(index, new Query("@first:Jo*")); - Assert.Equal(0, asOriginal.TotalResults); - SearchResult asAttribute = await ft.SearchAsync(index, new Query("@given:Jo*")); Assert.Equal(2, asAttribute.TotalResults); @@ -694,6 +703,19 @@ public async Task CreateWithFieldNamesAsync(string endpointId) Assert.Equal(1, nonAttribute.TotalResults); } + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task FailWhenAttributeNotExistAsync(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + var ft = db.FT(); + Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) + .AddField(new TextField(FieldName.Of("last"))); + + Assert.True(await ft.CreateAsync(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc)); + RedisServerException exc = await Assert.ThrowsAsync(async () => await ft.SearchAsync(index, new Query("@first:Jo*"))); + } + [SkipIfRedis(Is.Enterprise)] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void AlterAdd(string endpointId) From 089cc9fa313dfad617c0757b0da257ff5ccf4889 Mon Sep 17 00:00:00 2001 From: atakavci Date: Mon, 27 Jan 2025 16:20:43 +0300 Subject: [PATCH 2/2] assert throws --- tests/NRedisStack.Tests/Search/SearchTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 8651cebe..9c40ce6c 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -669,9 +669,7 @@ public void FailWhenAttributeNotExist(string endpointId) .AddField(new TextField(FieldName.Of("last"))); Assert.True(ft.Create(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc)); - - SearchResult asOriginal = ft.Search(index, new Query("@first:Jo*")); - Assert.Equal(0, asOriginal.TotalResults); + RedisServerException exc = Assert.Throws(() => ft.Search(index, new Query("@first:Jo*"))); } [SkippableTheory]