finish index feature
This commit is contained in:
@@ -223,19 +223,19 @@ func TestIndexEncodedCollectionCache(t *testing.T) {
|
||||
if !foundInCache {
|
||||
t.Error("Expected to find bob record in raw cache with updated name")
|
||||
}
|
||||
// Проверяем индекс: по email bob@secret.com должна быть одна строка, по name bob_updated — тоже
|
||||
// Проверяем индекс: по email bob@secret.com должна быть одна позиция, по name bob_updated — тоже
|
||||
idxSnapshot := db.GetIndexSnapshotForTest("give_me_cache")
|
||||
if len(idxSnapshot) == 0 {
|
||||
t.Error("Expected index snapshot to have entries")
|
||||
}
|
||||
if emailIdx, ok := idxSnapshot["users:email"].(map[string][]int); ok {
|
||||
if lines, ok := emailIdx["bob@secret.com"]; !ok || len(lines) != 1 {
|
||||
t.Errorf("Expected index users:email bob@secret.com to have 1 line, got %v", emailIdx["bob@secret.com"])
|
||||
if emailIdx, ok := idxSnapshot["users:email"].(map[string][]linedb.IndexPosition); ok {
|
||||
if positions, ok := emailIdx["bob@secret.com"]; !ok || len(positions) != 1 {
|
||||
t.Errorf("Expected index users:email bob@secret.com to have 1 position, got %v", emailIdx["bob@secret.com"])
|
||||
}
|
||||
}
|
||||
if nameIdx, ok := idxSnapshot["users:name"].(map[string][]int); ok {
|
||||
if lines, ok := nameIdx["bob_updated"]; !ok || len(lines) != 1 {
|
||||
t.Errorf("Expected index users:name bob_updated to have 1 line, got %v", nameIdx["bob_updated"])
|
||||
if nameIdx, ok := idxSnapshot["users:name"].(map[string][]linedb.IndexPosition); ok {
|
||||
if positions, ok := nameIdx["bob_updated"]; !ok || len(positions) != 1 {
|
||||
t.Errorf("Expected index users:name bob_updated to have 1 position, got %v", nameIdx["bob_updated"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,14 +265,14 @@ func TestIndexEncodedCollectionCache(t *testing.T) {
|
||||
}
|
||||
// Индекс: bob@secret.com и bob_updated не должны быть в индексе (или пустые срезы)
|
||||
idxSnapshot2 := db.GetIndexSnapshotForTest("give_me_cache")
|
||||
if emailIdx, ok := idxSnapshot2["users:email"].(map[string][]int); ok {
|
||||
if lines, has := emailIdx["bob@secret.com"]; has && len(lines) > 0 {
|
||||
t.Errorf("After delete, index users:email bob@secret.com should be empty, got %v", lines)
|
||||
if emailIdx, ok := idxSnapshot2["users:email"].(map[string][]linedb.IndexPosition); ok {
|
||||
if positions, has := emailIdx["bob@secret.com"]; has && len(positions) > 0 {
|
||||
t.Errorf("After delete, index users:email bob@secret.com should be empty, got %v", positions)
|
||||
}
|
||||
}
|
||||
if nameIdx, ok := idxSnapshot2["users:name"].(map[string][]int); ok {
|
||||
if lines, has := nameIdx["bob_updated"]; has && len(lines) > 0 {
|
||||
t.Errorf("After delete, index users:name bob_updated should be empty, got %v", lines)
|
||||
if nameIdx, ok := idxSnapshot2["users:name"].(map[string][]linedb.IndexPosition); ok {
|
||||
if positions, has := nameIdx["bob_updated"]; has && len(positions) > 0 {
|
||||
t.Errorf("After delete, index users:name bob_updated should be empty, got %v", positions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user