Skip to content

Commit a8f68a9

Browse files
authored
Changing behaviours in Redis CE 8.0 (#388)
* changing behaviours in CE 8.0 * assert throws
1 parent 8a17e47 commit a8f68a9

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

tests/NRedisStack.Tests/Search/SearchTests.cs

+26-6
Original file line numberDiff line numberDiff line change
@@ -652,16 +652,26 @@ public void CreateWithFieldNames(string endpointId)
652652
SearchResult noFilters = ft.Search(index, new Query());
653653
Assert.Equal(5, noFilters.TotalResults);
654654

655-
SearchResult asOriginal = ft.Search(index, new Query("@first:Jo*"));
656-
Assert.Equal(0, asOriginal.TotalResults);
657-
658655
SearchResult asAttribute = ft.Search(index, new Query("@given:Jo*"));
659656
Assert.Equal(2, asAttribute.TotalResults);
660657

661658
SearchResult nonAttribute = ft.Search(index, new Query("@last:Rod"));
662659
Assert.Equal(1, nonAttribute.TotalResults);
663660
}
664661

662+
[SkipIfRedis(Comparison.LessThan, "7.9.0")]
663+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
664+
public void FailWhenAttributeNotExist(string endpointId)
665+
{
666+
IDatabase db = GetCleanDatabase(endpointId);
667+
var ft = db.FT();
668+
Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given")))
669+
.AddField(new TextField(FieldName.Of("last")));
670+
671+
Assert.True(ft.Create(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc));
672+
RedisServerException exc = Assert.Throws<RedisServerException>(() => ft.Search(index, new Query("@first:Jo*")));
673+
}
674+
665675
[SkippableTheory]
666676
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
667677
public async Task CreateWithFieldNamesAsync(string endpointId)
@@ -684,16 +694,26 @@ public async Task CreateWithFieldNamesAsync(string endpointId)
684694
SearchResult noFilters = await ft.SearchAsync(index, new Query());
685695
Assert.Equal(5, noFilters.TotalResults);
686696

687-
SearchResult asOriginal = await ft.SearchAsync(index, new Query("@first:Jo*"));
688-
Assert.Equal(0, asOriginal.TotalResults);
689-
690697
SearchResult asAttribute = await ft.SearchAsync(index, new Query("@given:Jo*"));
691698
Assert.Equal(2, asAttribute.TotalResults);
692699

693700
SearchResult nonAttribute = await ft.SearchAsync(index, new Query("@last:Rod"));
694701
Assert.Equal(1, nonAttribute.TotalResults);
695702
}
696703

704+
[SkipIfRedis(Comparison.LessThan, "7.9.0")]
705+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
706+
public async Task FailWhenAttributeNotExistAsync(string endpointId)
707+
{
708+
IDatabase db = GetCleanDatabase(endpointId);
709+
var ft = db.FT();
710+
Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given")))
711+
.AddField(new TextField(FieldName.Of("last")));
712+
713+
Assert.True(await ft.CreateAsync(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc));
714+
RedisServerException exc = await Assert.ThrowsAsync<RedisServerException>(async () => await ft.SearchAsync(index, new Query("@first:Jo*")));
715+
}
716+
697717
[SkipIfRedis(Is.Enterprise)]
698718
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
699719
public void AlterAdd(string endpointId)

0 commit comments

Comments
 (0)