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 6, 2025
1 parent f0c4a49 commit 697afea
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 28 deletions.
6 changes: 6 additions & 0 deletions internal/db/base/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package base

import (
"bytes"
"strings"
"time"
)
Expand Down Expand Up @@ -44,6 +45,8 @@ func Compare(a, b any) int {
return compareTime(v, b.(time.Time))
case string:
return compareString(v, b.(string))
case []byte:
return compareBytes(v, b.([]byte))
default:
return 0
}
Expand Down Expand Up @@ -93,3 +96,6 @@ func compareTime(a, b time.Time) int {
func compareString(a, b string) int {
return strings.Compare(a, b)
}
func compareBytes(a, b []byte) int {
return bytes.Compare(a, b)
}
2 changes: 0 additions & 2 deletions tests/integration/query/simple/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ var userCollectionGQLSchema = (`
Email: String
Age: Int
HeightM: Float
Points: Float32
Raw: Blob
Verified: Boolean
CreatedAt: DateTime
}
Expand Down
88 changes: 62 additions & 26 deletions tests/integration/query/simple/with_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func TestQuerySimpleWithEmptyOrder(t *testing.T) {
}`,
Results: map[string]any{
"Users": []map[string]any{
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "Carlo",
"Age": int64(55),
},
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "John",
"Age": int64(21),
Expand Down Expand Up @@ -134,6 +134,12 @@ func TestQuerySimpleWithFloat32OrderAscending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order ASC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
Points: Float32
}`,
},
testUtils.CreateDoc{
Doc: `{
"Name": "John",
Expand Down Expand Up @@ -189,13 +195,19 @@ func TestQuerySimpleWithFloat32OrderAscending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWithFloat64OrderAscending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order ASC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
HeightM: Float
}`,
},
testUtils.CreateDoc{
Doc: `{
"Name": "John",
Expand Down Expand Up @@ -251,13 +263,19 @@ func TestQuerySimpleWithFloat64OrderAscending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWithBlobOrderAscending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order ASC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
Raw: Blob
}`,
},
testUtils.CreateDoc{
DocMap: map[string]any{
"Name": "John",
Expand Down Expand Up @@ -313,7 +331,7 @@ func TestQuerySimpleWithBlobOrderAscending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWithDateTimeOrderAscending(t *testing.T) {
Expand Down Expand Up @@ -448,6 +466,12 @@ func TestQuerySimpleWithFloat32OrderDescending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order DESC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
Points: Float32
}`,
},
testUtils.CreateDoc{
Doc: `{
"Name": "John",
Expand Down Expand Up @@ -503,13 +527,19 @@ func TestQuerySimpleWithFloat32OrderDescending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWitFloat64OrderDescending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order DESC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
HeightM: Float
}`,
},
testUtils.CreateDoc{
Doc: `{
"Name": "John",
Expand Down Expand Up @@ -565,13 +595,19 @@ func TestQuerySimpleWitFloat64OrderDescending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWithBlobOrderDescending(t *testing.T) {
test := testUtils.TestCase{
Description: "Simple query with basic order DESC",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `type Users {
Name: String
Raw: Blob
}`,
},
testUtils.CreateDoc{
DocMap: map[string]any{
"Name": "John",
Expand Down Expand Up @@ -627,7 +663,7 @@ func TestQuerySimpleWithBlobOrderDescending(t *testing.T) {
},
}

executeTestCase(t, test)
testUtils.ExecuteTestCase(t, test)
}

func TestQuerySimpleWithDateTimeOrderDescending(t *testing.T) {
Expand Down Expand Up @@ -1071,22 +1107,22 @@ func TestQuerySimple_WithEmptyAliasOrder_ShouldDoNothing(t *testing.T) {
}`,
Results: map[string]any{
"Users": []map[string]any{
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "Alice",
"Age": int64(19),
},
{
"Name": "Carlo",
"Age": int64(55),
},
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "John",
"Age": int64(21),
},
{
"Name": "Alice",
"Age": int64(19),
},
},
},
},
Expand Down Expand Up @@ -1133,22 +1169,22 @@ func TestQuerySimple_WithNullAliasOrder_ShouldDoNothing(t *testing.T) {
}`,
Results: map[string]any{
"Users": []map[string]any{
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "Alice",
"Age": int64(19),
},
{
"Name": "Carlo",
"Age": int64(55),
},
{
"Name": "Bob",
"Age": int64(32),
},
{
"Name": "John",
"Age": int64(21),
},
{
"Name": "Alice",
"Age": int64(19),
},
},
},
},
Expand Down

0 comments on commit 697afea

Please sign in to comment.