Skip to content

Commit

Permalink
fix TestMemorySearch
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalef committed Sep 17, 2023
1 parent e7ec94a commit 8f5313b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/store/postgres/search_memory_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package postgres

import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"
"time"

"github.com/getzep/zep/pkg/extractors"

"github.com/uptrace/bun"

"github.com/getzep/zep/pkg/models"
"github.com/getzep/zep/pkg/testutils"
"github.com/stretchr/testify/assert"
)

func TestVectorSearch(t *testing.T) {
func TestMemorySearch(t *testing.T) {
// Test data
sessionID, err := testutils.GenerateRandomSessionID(16)
assert.NoError(t, err, "GenerateRandomSessionID should not return an error")
Expand All @@ -24,12 +25,9 @@ func TestVectorSearch(t *testing.T) {
msgs, err := putMessages(testCtx, testDB, sessionID, testutils.TestMessages)
assert.NoError(t, err, "putMessages should not return an error")

appState.MemoryStore.NotifyExtractors(
context.Background(),
appState,
&models.MessageEvent{SessionID: sessionID,
Messages: msgs},
)
e := extractors.NewEmbeddingExtractor()
err = e.Extract(testCtx, appState, &models.MessageEvent{SessionID: sessionID, Messages: msgs})
assert.NoError(t, err, "EmbeddingExtractor.Extract should not return an error")

// enrichment runs async. Wait for it to finish
// This is hacky but I'd prefer not to add a WaitGroup to the putMessages function just for testing purposes
Expand Down Expand Up @@ -74,7 +72,6 @@ func TestVectorSearch(t *testing.T) {
assert.NotNil(t, res.Message.CreatedAt, "message__created_at should be present")
assert.NotNil(t, res.Message.Role, "message__role should be present")
assert.NotNil(t, res.Message.Content, "message__content should be present")
assert.NotZero(t, res.Message.TokenCount, "message_token_count should be present")
}
}
})
Expand Down

0 comments on commit 8f5313b

Please sign in to comment.