Skip to content

Commit

Permalink
use typesense v27.0 & update integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
phiHero committed Sep 29, 2024
1 parent ab589e8 commit 412393e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
services:
typesense:
image: typesense/typesense:26.0
image: typesense/typesense:27.0
ports:
- 8108:8108/tcp
volumes:
Expand Down
1 change: 1 addition & 0 deletions typesense/api/pointer/pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Interface(v interface{}) *interface{} {
func String(v string) *string {
return &v
}

func Any[T any](v T) *T {
return &v
}
4 changes: 2 additions & 2 deletions typesense/overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
func createNewSearchOverrideSchema() *api.SearchOverrideSchema {
return &api.SearchOverrideSchema{
Rule: api.SearchOverrideRule{
Query: "apple",
Match: "exact",
Query: pointer.String("apple"),
Match: pointer.Any(api.Exact),
},
Includes: &[]api.SearchOverrideInclude{
{
Expand Down
11 changes: 9 additions & 2 deletions typesense/test/dbhelpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
Locale: pointer.String(""),
Sort: pointer.False(),
Drop: nil,
Store: pointer.True(),
},
{
Name: "num_employees",
Expand All @@ -67,6 +68,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
Locale: pointer.String(""),
Sort: pointer.True(),
Drop: nil,
Store: pointer.True(),
},
{
Name: "country",
Expand All @@ -78,6 +80,7 @@ func expectedNewCollection(name string) *api.CollectionResponse {
Locale: pointer.String(""),
Sort: pointer.False(),
Drop: nil,
Store: pointer.True(),
},
},
EnableNestedFields: pointer.False(),
Expand Down Expand Up @@ -191,7 +194,7 @@ func newSearchOverrideSchema() *api.SearchOverrideSchema {
schema := &api.SearchOverrideSchema{
Rule: api.SearchOverrideRule{
Query: pointer.String("apple"),
Match: (*api.SearchOverrideRuleMatch)(pointer.String("exact")),
Match: pointer.Any(api.Exact),
},
Includes: &[]api.SearchOverrideInclude{
{
Expand All @@ -209,6 +212,8 @@ func newSearchOverrideSchema() *api.SearchOverrideSchema {
},
},
RemoveMatchedTokens: pointer.True(),
FilterCuratedHits: pointer.False(),
StopProcessing: pointer.True(),
}

return schema
Expand All @@ -219,7 +224,7 @@ func newSearchOverride(overrideID string) *api.SearchOverride {
Id: pointer.String(overrideID),
Rule: api.SearchOverrideRule{
Query: pointer.String("apple"),
Match: (*api.SearchOverrideRuleMatch)(pointer.String("exact")),
Match: pointer.Any(api.Exact),
},
Includes: &[]api.SearchOverrideInclude{
{
Expand All @@ -237,6 +242,8 @@ func newSearchOverride(overrideID string) *api.SearchOverride {
},
},
RemoveMatchedTokens: pointer.True(),
FilterCuratedHits: pointer.False(),
StopProcessing: pointer.True(),
}
}

Expand Down
7 changes: 4 additions & 3 deletions typesense/test/overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/typesense/typesense-go/v2/typesense/api"
"github.com/typesense/typesense-go/v2/typesense/api/pointer"
)

func TestSearchOverrideUpsertNewOverride(t *testing.T) {
Expand All @@ -33,14 +34,14 @@ func TestSearchOverrideUpsertExistingOverride(t *testing.T) {
collectionName := createNewCollection(t, "companies")
overrideID := newUUIDName("customize-apple")
expectedResult := newSearchOverride(overrideID)
expectedResult.Rule.Match = "contains"
expectedResult.Rule.Match = pointer.Any(api.Contains)

body := newSearchOverrideSchema()
body.Rule.Match = "exact"
body.Rule.Match = pointer.Any(api.Exact)
_, err := typesenseClient.Collection(collectionName).Overrides().Upsert(context.Background(), overrideID, body)
require.NoError(t, err)

body.Rule.Match = "contains"
body.Rule.Match = pointer.Any(api.Contains)

result, err := typesenseClient.Collection(collectionName).Overrides().Upsert(context.Background(), overrideID, body)

Expand Down

0 comments on commit 412393e

Please sign in to comment.