Skip to content

Commit 31c89a0

Browse files
committed
noot
1 parent 52acd4f commit 31c89a0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

typesense/test/dbhelpers_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ func newDocumentResponse(docID string, opts ...newDocumentResponseOption) map[st
155155
return document
156156
}
157157

158+
func newStructResponse(docID string, opts ...func(*testDocument)) *testDocument {
159+
document := &testDocument{}
160+
document.ID = docID
161+
document.CompanyName = "Stark Industries"
162+
document.NumEmployees = 5215
163+
document.Country = "USA"
164+
for _, opt := range opts {
165+
opt(document)
166+
}
167+
return document
168+
}
169+
158170
func newKeySchema() *api.ApiKeySchema {
159171
return &api.ApiKeySchema{
160172
Description: "Search-only key.",

typesense/test/document_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ import (
88
"testing"
99

1010
"github.com/stretchr/testify/require"
11+
"github.com/typesense/typesense-go/typesense"
1112
)
1213

14+
func TestDocumentRetrieveGeneric(t *testing.T) {
15+
collectionName := createNewCollection(t, "companies")
16+
expectedResult := newStructResponse("123")
17+
createDocument(t, collectionName, newDocument("123"))
18+
result, err := typesense.GenericCollection[*testDocument](typesenseClient, collectionName).Document("123").Retrieve(context.Background())
19+
20+
require.NoError(t, err)
21+
require.Equal(t, expectedResult, result)
22+
}
23+
1324
func TestDocumentRetrieve(t *testing.T) {
1425
collectionName := createNewCollection(t, "companies")
1526
expectedResult := newDocumentResponse("123")

0 commit comments

Comments
 (0)