Skip to content

Commit

Permalink
noot
Browse files Browse the repository at this point in the history
  • Loading branch information
elee1766 committed Apr 30, 2024
1 parent 52acd4f commit 31c89a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions typesense/test/dbhelpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ func newDocumentResponse(docID string, opts ...newDocumentResponseOption) map[st
return document
}

func newStructResponse(docID string, opts ...func(*testDocument)) *testDocument {
document := &testDocument{}
document.ID = docID
document.CompanyName = "Stark Industries"
document.NumEmployees = 5215
document.Country = "USA"
for _, opt := range opts {
opt(document)
}
return document
}

func newKeySchema() *api.ApiKeySchema {
return &api.ApiKeySchema{
Description: "Search-only key.",
Expand Down
11 changes: 11 additions & 0 deletions typesense/test/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/typesense/typesense-go/typesense"
)

func TestDocumentRetrieveGeneric(t *testing.T) {
collectionName := createNewCollection(t, "companies")
expectedResult := newStructResponse("123")
createDocument(t, collectionName, newDocument("123"))
result, err := typesense.GenericCollection[*testDocument](typesenseClient, collectionName).Document("123").Retrieve(context.Background())

require.NoError(t, err)
require.Equal(t, expectedResult, result)
}

func TestDocumentRetrieve(t *testing.T) {
collectionName := createNewCollection(t, "companies")
expectedResult := newDocumentResponse("123")
Expand Down

0 comments on commit 31c89a0

Please sign in to comment.