Skip to content

Commit

Permalink
Changing behaviours in Redis CE 8.0 (#388)
Browse files Browse the repository at this point in the history
* changing behaviours in CE 8.0

* assert throws
  • Loading branch information
atakavci authored Jan 29, 2025
1 parent 8a17e47 commit a8f68a9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,26 @@ 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);

SearchResult nonAttribute = ft.Search(index, new Query("@last:Rod"));
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));
RedisServerException exc = Assert.Throws<RedisServerException>(() => ft.Search(index, new Query("@first:Jo*")));

Check failure on line 672 in tests/NRedisStack.Tests/Search/SearchTests.cs

View workflow job for this annotation

GitHub Actions / Redis 8.0-M02; .NET 7.0;

NRedisStack.Tests.Search.SearchTests.FailWhenAttributeNotExist(endpointId: "standalone")

Assert.Throws() Failure: No exception was thrown Expected: typeof(StackExchange.Redis.RedisServerException)
}

[SkippableTheory]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public async Task CreateWithFieldNamesAsync(string endpointId)
Expand All @@ -684,16 +694,26 @@ 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);

SearchResult nonAttribute = await ft.SearchAsync(index, new Query("@last:Rod"));
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<RedisServerException>(async () => await ft.SearchAsync(index, new Query("@first:Jo*")));

Check failure on line 714 in tests/NRedisStack.Tests/Search/SearchTests.cs

View workflow job for this annotation

GitHub Actions / Redis 8.0-M02; .NET 7.0;

NRedisStack.Tests.Search.SearchTests.FailWhenAttributeNotExistAsync(endpointId: "standalone")

Assert.Throws() Failure: No exception was thrown Expected: typeof(StackExchange.Redis.RedisServerException)
}

[SkipIfRedis(Is.Enterprise)]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public void AlterAdd(string endpointId)
Expand Down

0 comments on commit a8f68a9

Please sign in to comment.