Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Feb 5, 2025
1 parent 7f1cb9b commit e54b83e
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 95 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,16 @@ deps\:playground:

/PHONY: deps\:embedding
deps\:embedding:
ifeq ($(OS_GENERAL), Linux)
curl -fsSL https://ollama.com/install.sh | sh &&
endif
ollama serve && \
ollama pull nomic-embed-text
ifeq ($(OS_GENERAL),Linux)
curl -fsSL https://ollama.com/install.sh | sh
else
# run ollama in the background
nohup ollama serve > ollama.log 2>&1 &
endif
# make sure ollama is running before continuing
time curl --retry 5 --retry-connrefused --retry-delay 0 -sf http://localhost:11434
# pull a model
ollama pull nomic-embed-text

.PHONY: deps
deps:
Expand Down
2 changes: 1 addition & 1 deletion tests/gen/gen_auto_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func checkAndValidateMinMax(field *client.FieldDefinition, conf *genConfig) erro
err = validateMinConfig[int](conf, field.Kind.IsArray())
} else if field.Kind == client.FieldKind_NILLABLE_FLOAT32 {
err = validateMinConfig[float32](conf, false)
} else if field.Kind == client.FieldKind_NILLABLE_FLOAT64 {
} else {
err = validateMinConfig[float64](conf, false)
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/backup/simple/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestBackupImport_WithMultipleNoKeysAndInvalidField_Errors(t *testing.T) {
{"INVALID":31,"name":"Smith"},
{"age":32,"name":"Bob"}
]}`,
ExpectedError: "The given field does not exist. Name: INVALID",
ExpectedError: "the given field does not exist. Name: INVALID",
},
testUtils.Request{
Request: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestMutationCreate_WithSizeConstrain_ShouldSucceed(t *testing.T) {
Request: `
query {
Users {
_docID
name
numbers
}
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/mutation/create/crdt/pcounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestPCounterCreate_IntKindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
Expand Down Expand Up @@ -78,15 +77,13 @@ func TestPCounterCreate_Float32KindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
}`,
Results: map[string]any{
"Users": []map[string]any{
{
"_docID": "bae-311c7181-a73a-5695-98af-8c1d5c14c7a3",
"name": "John",
"points": float32(10.1),
},
Expand Down Expand Up @@ -120,15 +117,13 @@ func TestPCounterCreate_Float64KindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
}`,
Results: map[string]any{
"Users": []map[string]any{
{
"_docID": "bae-f7238bdc-2610-532c-a8ae-564f9ad8ee9f",
"name": "John",
"points": float64(10.1),
},
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/mutation/create/crdt/pncounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestPNCounterCreate_IntKindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
Expand Down Expand Up @@ -78,7 +77,6 @@ func TestPNCounterCreate_Float32KindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
Expand Down Expand Up @@ -119,7 +117,6 @@ func TestPNCounterCreate_Float64KindWithPositiveValue_NoError(t *testing.T) {
testUtils.Request{
Request: `query {
Users {
_docID
name
points
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestMutationCreate_WithNonExistantField_ShouldError(t *testing.T) {
name_v: [Float32!] @embedding(fields: ["name", "about"])
}
`,
ExpectedError: "the given field does not exist. Embedding field: about",
ExpectedError: "the given field does not exist. Embedding generation field: about",
},
},
}
Expand Down Expand Up @@ -189,7 +189,6 @@ func TestMutationCreate_WithMultipleEmbeddingFields_ShouldSucceed(t *testing.T)
Request: `
query {
User {
_docID
name_v
}
}
Expand Down Expand Up @@ -227,7 +226,7 @@ func TestMutationCreate_UserDefinedVectorEmbeddingDoesNotTriggerGeneration_Shoul
testUtils.CreateDoc{
Doc: `{
"name": "John",
"about": "He loves tacos."
"about": "He loves tacos.",
"name_v": [1, 2, 3]
}`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestMutationCreateOneToMany_AliasedRelationNameWithInvalidField_Error(t *te
"notName": "Painted House",
"author": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand All @@ -56,7 +56,7 @@ func TestMutationCreateOneToMany_AliasedRelationNameNonExistingRelationSingleSid
"name": "John Grisham",
"published": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: published",
ExpectedError: "the given field does not exist. Name: published",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestMutationCreateOneToMany_WithInvalidField_Error(t *testing.T) {
"notName": "Painted House",
"author_id": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand All @@ -56,7 +56,7 @@ func TestMutationCreateOneToMany_NonExistingRelationSingleSide_NoIDFieldError(t
"name": "John Grisham",
"published_id": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: published_id",
ExpectedError: "the given field does not exist. Name: published_id",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMutationCreateOneToOne_UseAliasWithInvalidField_Error(t *testing.T) {
"notName": "John Grisham",
"published": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMutationCreateOneToOne_WithInvalidField_Error(t *testing.T) {
"notName": "John Grisham",
"published_id": "bae-be6d8024-4953-5a92-84b4-f042d25230c6"
}`,
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/mutation/create/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestMutationCreate_GivenNonExistantField_Errors(t *testing.T) {
"name": "John",
"fieldDoesNotExist": 27
}`,
ExpectedError: "The given field does not exist. Name: fieldDoesNotExist",
ExpectedError: "the given field does not exist. Name: fieldDoesNotExist",
},
testUtils.Request{
// Ensure that no documents have been written.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestMutationUpdate_WithSizeConstrain_ShouldSucceed(t *testing.T) {
Request: `
query {
Users {
_docID
name
numbers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestMutationUpdate_WithMultipleEmbeddingFields_ShouldSucceed(t *testing.T)
Request: `
query {
User {
_docID
name_v
}
}
Expand Down Expand Up @@ -112,7 +111,6 @@ func TestMutationUpdate_UserDefinedVectorEmbeddingDoesNotTriggerGeneration_Shoul
Request: `
query {
User {
_docID
name_v
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestMutationUpdateOneToMany_RelationIDToLinkFromSingleSide_Error(t *testing
}`,
bookID,
),
ExpectedError: "The given field does not exist. Name: published_id",
ExpectedError: "the given field does not exist. Name: published_id",
},
},
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestMutationUpdateOneToMany_RelationIDToLinkFromManySideWithWrongField_Erro
}`,
author2ID,
),
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestMutationUpdateOneToMany_AliasRelationNameToLinkFromManySideWithWrongFie
}`,
author2ID,
),
ExpectedError: "The given field does not exist. Name: notName",
ExpectedError: "the given field does not exist. Name: notName",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/query/one_to_many/with_sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestQueryOneToMany_WithSumAliasFilterOnFloat32_ShouldMatchOne(t *testing.T)
"Author": []map[string]any{
{
"name": "John Grisham",
"totalRating": 9.4,
"totalRating": 9.400000095367432,
},
},
},
Expand Down
18 changes: 17 additions & 1 deletion tests/integration/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ func areResultsEqual(expected any, actual any) bool {
return false
}
return assert.ObjectsAreEqualValues(expected, actualVal)
case float32, float64:
case float32:
jsonNum, ok := actual.(json.Number)
if !ok {
return assert.ObjectsAreEqualValues(expected, actual)
}
actualVal, err := jsonNum.Float64()
if err != nil {
return false
}
return assert.ObjectsAreEqualValues(expected, float32(actualVal))
case float64:
jsonNum, ok := actual.(json.Number)
if !ok {
return assert.ObjectsAreEqualValues(expected, actual)
Expand All @@ -175,6 +185,8 @@ func areResultsEqual(expected any, actual any) bool {
return false
}
return assert.ObjectsAreEqualValues(expected, actualVal)
case immutable.Option[float32]:
return areResultOptionsEqual(expectedVal, actual)
case immutable.Option[float64]:
return areResultOptionsEqual(expectedVal, actual)
case immutable.Option[uint64]:
Expand All @@ -191,6 +203,8 @@ func areResultsEqual(expected any, actual any) bool {
return areResultArraysEqual(expectedVal, actual)
case []uint64:
return areResultArraysEqual(expectedVal, actual)
case []float32:
return areResultArraysEqual(expectedVal, actual)
case []float64:
return areResultArraysEqual(expectedVal, actual)
case []string:
Expand All @@ -201,6 +215,8 @@ func areResultsEqual(expected any, actual any) bool {
return areResultArraysEqual(expectedVal, actual)
case []map[string]any:
return areResultArraysEqual(expectedVal, actual)
case []immutable.Option[float32]:
return areResultArraysEqual(expectedVal, actual)
case []immutable.Option[float64]:
return areResultArraysEqual(expectedVal, actual)
case []immutable.Option[uint64]:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/schema/crdt_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestSchemaCreate_ContainsPCounterTypeWithFloat64Kind_NoError(t *testing.T)
}

func TestSchemaCreate_ContainsPCounterTypeWithFloat32Kind_NoError(t *testing.T) {
schemaVersionID := "bafkreiaaxlm4lyqhdntsuvaotxqi2essky7oae34n7lyupqy64mxbtfwu4"
schemaVersionID := "bafkreicza5tsxxy7v5qj2bbsd7ox6jrdaypwqk4qm4qda52wr6pwkis3cy"

test := testUtils.TestCase{
Actions: []any{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

func TestSchemaUpdatesAddFieldKindFloat32Array(t *testing.T) {
test := testUtils.TestCase{
Description: "Test schema update, add field with kind float32 array (23)",
Description: "Test schema update, add field with kind float32 array (9)",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
Expand All @@ -30,7 +30,7 @@ func TestSchemaUpdatesAddFieldKindFloat32Array(t *testing.T) {
testUtils.SchemaPatch{
Patch: `
[
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 23} }
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 9} }
]
`,
},
Expand All @@ -52,7 +52,7 @@ func TestSchemaUpdatesAddFieldKindFloat32Array(t *testing.T) {

func TestSchemaUpdatesAddFieldKindFloat32ArrayWithCreate(t *testing.T) {
test := testUtils.TestCase{
Description: "Test schema update, add field with kind float32 array (23) with create",
Description: "Test schema update, add field with kind float32 array (9) with create",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
Expand All @@ -64,7 +64,7 @@ func TestSchemaUpdatesAddFieldKindFloat32ArrayWithCreate(t *testing.T) {
testUtils.SchemaPatch{
Patch: `
[
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 23} }
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 9} }
]
`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

func TestSchemaUpdatesAddFieldKindNillableFloat32Array(t *testing.T) {
test := testUtils.TestCase{
Description: "Test schema update, add field with kind nillable float32 array (24)",
Description: "Test schema update, add field with kind nillable float32 array (22)",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
Expand All @@ -32,7 +32,7 @@ func TestSchemaUpdatesAddFieldKindNillableFloat32Array(t *testing.T) {
testUtils.SchemaPatch{
Patch: `
[
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 24} }
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 22} }
]
`,
},
Expand All @@ -54,7 +54,7 @@ func TestSchemaUpdatesAddFieldKindNillableFloat32Array(t *testing.T) {

func TestSchemaUpdatesAddFieldKindNillableFloat32ArrayWithCreate(t *testing.T) {
test := testUtils.TestCase{
Description: "Test schema update, add field with kind nillable int array (24) with create",
Description: "Test schema update, add field with kind nillable int array (22) with create",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
Expand All @@ -66,7 +66,7 @@ func TestSchemaUpdatesAddFieldKindNillableFloat32ArrayWithCreate(t *testing.T) {
testUtils.SchemaPatch{
Patch: `
[
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 24} }
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "foo", "Kind": 22} }
]
`,
},
Expand Down
Loading

0 comments on commit e54b83e

Please sign in to comment.