Pre-release clean up.
This commit is contained in:
parent
23a27033a4
commit
b817f57035
27 changed files with 628 additions and 79 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
|
||||
|
|
@ -14,8 +13,6 @@ func TestAllTypesSelect(t *testing.T) {
|
|||
dest := []model.AllTypes{}
|
||||
|
||||
err := AllTypes.SELECT(AllTypes.AllColumns).Query(db, &dest)
|
||||
|
||||
fmt.Println(err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.DeepEqual(t, dest[0], allTypesRow0)
|
||||
|
|
|
|||
|
|
@ -188,18 +188,26 @@ VALUES
|
|||
|
||||
-- Person table ------------------
|
||||
|
||||
DROP TABLE IF EXISTS test_sample.person;
|
||||
|
||||
CREATE TABLE test_sample.person(
|
||||
person_id uuid,
|
||||
first_name varchar(100),
|
||||
last_name varchar(100)
|
||||
);
|
||||
|
||||
DROP TYPE IF EXISTS test_sample.MOOD CASCADE;
|
||||
|
||||
CREATE TYPE test_sample.MOOD AS ENUM ('sad', 'ok', 'happy');
|
||||
|
||||
DROP TABLE IF EXISTS test_sample.person;
|
||||
|
||||
|
||||
CREATE TABLE test_sample.person(
|
||||
person_id uuid NOT NULL PRIMARY KEY,
|
||||
first_name varchar(100),
|
||||
last_name varchar(100),
|
||||
"Mood" test_sample.mood
|
||||
);
|
||||
|
||||
INSERT INTO test_sample.person(person_id, first_name, last_name, "Mood") VALUES
|
||||
('b68dbff4-a87d-11e9-a7f2-98ded00c39c6', 'Sad', 'John', 'sad'),
|
||||
('b68dbff5-a87d-11e9-a7f2-98ded00c39c7', 'Ok', 'John', 'ok'),
|
||||
('b68dbff6-a87d-11e9-a7f2-98ded00c39c8', 'Ok', 'John', 'ok');
|
||||
|
||||
|
||||
|
||||
-- WEIRD TABLE NAMES --------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/table"
|
||||
"gotest.tools/assert"
|
||||
|
|
@ -61,8 +60,6 @@ func TestNorthwindJoinEverything(t *testing.T) {
|
|||
err := stmt.Query(db, &dest)
|
||||
assert.NilError(t, err)
|
||||
|
||||
fmt.Println(len(dest))
|
||||
|
||||
//jsonSave("./testdata/northwind-all.json", dest)
|
||||
assertJsonFile(t, "./testdata/northwind-all.json", dest)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
. "github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
|
||||
|
|
@ -35,30 +33,41 @@ func TestEnumType(t *testing.T) {
|
|||
query := Person.
|
||||
SELECT(Person.AllColumns)
|
||||
|
||||
queryStr, args, err := query.Sql()
|
||||
assertStatementSql(t, query, `
|
||||
SELECT person.person_id AS "person.person_id",
|
||||
person.first_name AS "person.first_name",
|
||||
person.last_name AS "person.last_name",
|
||||
person."Mood" AS "person.Mood"
|
||||
FROM test_sample.person;
|
||||
`)
|
||||
|
||||
assert.NilError(t, err)
|
||||
fmt.Println(queryStr)
|
||||
assert.Equal(t, len(args), 0)
|
||||
result := []model.Person{}
|
||||
|
||||
err = query.Query(db, &result)
|
||||
err := query.Query(db, &result)
|
||||
|
||||
assert.NilError(t, err)
|
||||
//spew.Dump(result)
|
||||
|
||||
type Person struct {
|
||||
Name string
|
||||
CurrentMood model.Mood
|
||||
assertJson(t, result, `
|
||||
[
|
||||
{
|
||||
"PersonID": "b68dbff4-a87d-11e9-a7f2-98ded00c39c6",
|
||||
"FirstName": "Sad",
|
||||
"LastName": "John",
|
||||
"Mood": "sad"
|
||||
},
|
||||
{
|
||||
"PersonID": "b68dbff5-a87d-11e9-a7f2-98ded00c39c7",
|
||||
"FirstName": "Ok",
|
||||
"LastName": "John",
|
||||
"Mood": "ok"
|
||||
},
|
||||
{
|
||||
"PersonID": "b68dbff6-a87d-11e9-a7f2-98ded00c39c8",
|
||||
"FirstName": "Ok",
|
||||
"LastName": "John",
|
||||
"Mood": "ok"
|
||||
}
|
||||
|
||||
result2 := []Person{}
|
||||
|
||||
err = query.Query(db, &result2)
|
||||
|
||||
assert.NilError(t, err)
|
||||
|
||||
spew.Dump(result2)
|
||||
]
|
||||
`)
|
||||
}
|
||||
|
||||
func TestSelecSelfJoin1(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
. "github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/table"
|
||||
|
|
@ -171,8 +169,6 @@ func TestScanToStruct(t *testing.T) {
|
|||
err := query.Query(db, &dest)
|
||||
|
||||
assert.Error(t, err, `jet: can't set int32 to int, at struct field: InventoryID int of type tests.Inventory. `)
|
||||
|
||||
fmt.Println(err)
|
||||
})
|
||||
|
||||
t.Run("type mismatch scanner type", func(t *testing.T) {
|
||||
|
|
@ -455,10 +451,6 @@ func TestScanToSlice(t *testing.T) {
|
|||
|
||||
err := query.Query(db, &dest)
|
||||
|
||||
fmt.Println(query.DebugSql())
|
||||
|
||||
spew.Dump(dest)
|
||||
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, dest.Film, film1)
|
||||
assert.DeepEqual(t, dest.IDs, []int32{1, 2, 3, 4, 5, 6, 7, 8})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
|
||||
|
|
@ -17,8 +16,6 @@ func TestUpdateValues(t *testing.T) {
|
|||
SET("Bong", "http://bong.com").
|
||||
WHERE(Link.Name.EQ(String("Bing")))
|
||||
|
||||
fmt.Println(query.DebugSql())
|
||||
|
||||
var expectedSql = `
|
||||
UPDATE test_sample.link
|
||||
SET (name, url) = ('Bong', 'http://bong.com')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue