fix(query): keys (#2755)

* fix: add keys to projections

* change to multiple tables

* query keys

* query keys

* fix race condition

* fix timer reset

* begin tests

* tests

* remove migration

* only send to keyChannel if not nil
This commit is contained in:
Livio Amstutz
2022-01-12 13:22:04 +01:00
committed by GitHub
parent ead61d240d
commit 9ab566fdeb
23 changed files with 927 additions and 419 deletions

View File

@@ -3,7 +3,6 @@ package query
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"errors"
"fmt"
"log"
@@ -13,7 +12,7 @@ import (
"github.com/DATA-DOG/go-sqlmock"
sq "github.com/Masterminds/squirrel"
"github.com/nsf/jsondiff"
"github.com/stretchr/testify/assert"
)
var (
@@ -58,8 +57,7 @@ func assertPrepare(t *testing.T, prepareFunc, expectedObject interface{}, sqlExp
return false
}
if !reflect.DeepEqual(object, expectedObject) {
prettyPrintDiff(t, expectedObject, object)
if !assert.Equal(t, expectedObject, object) {
return false
}
@@ -315,19 +313,3 @@ func TestValidatePrepare(t *testing.T) {
})
}
}
func prettyPrintDiff(t *testing.T, expected, gotten interface{}) {
t.Helper()
expectedMarshalled, _ := json.Marshal(expected)
objectMarshalled, _ := json.Marshal(gotten)
_, diff := jsondiff.Compare(
expectedMarshalled,
objectMarshalled,
&jsondiff.Options{
SkipMatches: true,
Indent: " ",
ChangedSeparator: " is expected, got ",
})
t.Errorf("unexpected object: want %T, got %T, difference:\n%s", expected, gotten, diff)
}