Commit da1bb6dc authored by Amos Wenger's avatar Amos Wenger

Make module, eschew wharf

parent 81c1bfd1
Pipeline #14197 failed with stage
in 13 seconds
......@@ -8,7 +8,7 @@ import (
"crawshaw.io/sqlite"
"crawshaw.io/sqlite/sqliteutil"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/stretchr/testify/assert"
)
......
......@@ -4,9 +4,9 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -36,14 +36,14 @@ func Test_BelongsTo(t *testing.T) {
Desc: "Consumer-grade flamethrowers",
}
t.Log("Saving one fate")
wtest.Must(t, c.Save(conn, someFate))
mtest.Must(t, c.Save(conn, someFate))
lea := &Human{
ID: 3,
FateID: someFate.ID,
}
t.Log("Saving one human")
wtest.Must(t, c.Save(conn, lea))
mtest.Must(t, c.Save(conn, lea))
t.Log("Preloading lea")
c.Preload(conn, lea, hades.Assoc("Fate"))
......@@ -60,11 +60,11 @@ func Test_BelongsTo(t *testing.T) {
Desc: "Book authorship",
},
}
wtest.Must(t, c.Save(conn, lea, hades.Assoc("Fate")))
mtest.Must(t, c.Save(conn, lea, hades.Assoc("Fate")))
fate := &Fate{}
found, err := c.SelectOne(conn, fate, builder.Eq{"id": 421})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
assert.EqualValues(t, "Book authorship", fate.Desc)
})
......@@ -74,19 +74,19 @@ func Test_BelongsTo(t *testing.T) {
ID: 3,
Desc: "Space rodeo",
}
wtest.Must(t, c.Save(conn, fate))
mtest.Must(t, c.Save(conn, fate))
human := &Human{
ID: 6,
FateID: 3,
}
wtest.Must(t, c.Save(conn, human))
mtest.Must(t, c.Save(conn, human))
joke := &Joke{
ID: "neuf",
HumanID: 6,
}
wtest.Must(t, c.Save(conn, joke))
mtest.Must(t, c.Save(conn, joke))
c.Preload(conn, joke, hades.Assoc("Human", hades.Assoc("Fate")))
assert.NotNil(t, joke.Human)
......
......@@ -4,9 +4,9 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -27,15 +27,15 @@ func Test_CompositePrimaryKey(t *testing.T) {
}
withContext(t, models, func(conn *sqlite.Conn, c *hades.Context) {
wtest.Must(t, c.Save(conn, &Profile{ID: 14}))
wtest.Must(t, c.Save(conn, &ProfileData{
mtest.Must(t, c.Save(conn, &Profile{ID: 14}))
mtest.Must(t, c.Save(conn, &ProfileData{
ProfileID: 14,
Key: "foo",
Value: "bar",
}))
dataCount, err := c.Count(conn, &ProfileData{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, dataCount, 1)
})
}
......@@ -55,6 +55,6 @@ func Test_SaveDuplicateCompositePrimaryKeys(t *testing.T) {
&Helicopter{A: 1, B: "hey"},
&Helicopter{A: 1, B: "hey"},
}
wtest.Must(t, c.Save(conn, hh))
mtest.Must(t, c.Save(conn, hh))
})
}
\ No newline at end of file
package hades
import (
"github.com/itchio/wharf/state"
"github.com/itchio/headway/state"
)
type Context struct {
......
......@@ -2,7 +2,7 @@ package hades
import (
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
)
func (c *Context) Count(conn *sqlite.Conn, model interface{}, cond builder.Cond) (int64, error) {
......
......@@ -4,7 +4,7 @@ import (
"reflect"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/pkg/errors"
)
......
......@@ -4,9 +4,9 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -37,10 +37,10 @@ func Test_Delete(t *testing.T) {
var count int64
var err error
wtest.Must(t, c.Save(conn, stories))
mtest.Must(t, c.Save(conn, stories))
count, err = c.Count(conn, &Story{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 3, count)
err = c.Delete(conn, &Story{}, builder.NewCond())
......@@ -48,15 +48,15 @@ func Test_Delete(t *testing.T) {
assert.Contains(t, err.Error(), "refusing to blindly")
err = c.Delete(conn, &Story{}, builder.Eq{"id": 1})
wtest.Must(t, err)
mtest.Must(t, err)
count, err = c.Count(conn, &Story{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 2, count)
err = c.Delete(conn, &Story{}, builder.Expr("1"))
assert.NoError(t, err, "must delete all with expr")
count, err = c.Count(conn, &Story{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 0, count)
})
}
......@@ -5,7 +5,7 @@ import (
"crawshaw.io/sqlite"
"crawshaw.io/sqlite/sqliteutil"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/pkg/errors"
)
......
module github.com/itchio/hades
go 1.12
require (
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 // indirect
crawshaw.io/sqlite v0.1.2
github.com/itchio/headway v0.0.0-20190702175331-a4c65c5306de
github.com/jinzhu/inflection v1.0.0
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709
xorm.io/builder v0.3.5
)
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 h1:yDf7ARQc637HoxDho7xjqdvO5ZA2Yb+xzv/fOnnvZzw=
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk=
crawshaw.io/sqlite v0.1.2 h1:N17234KSbrpALUSEJ5AjTTf1u5Oym+FCXpBAs9Vi2Z4=
crawshaw.io/sqlite v0.1.2/go.mod h1:BZaitnE9BVpocOuCdi/y5XReJMUelG53e/rDSLwSFzY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/itchio/headway v0.0.0-20190702175331-a4c65c5306de h1:RQW9xPqYtvjdHHRZR95XsaEA9B4URCuNHK78IuJcc+Y=
github.com/itchio/headway v0.0.0-20190702175331-a4c65c5306de/go.mod h1:Iif+7HeesRB0PvTYf0gOIFX8lj0za0SUsWryENQYt1E=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 h1:Ko2LQMrRU+Oy/+EDBwX7eZ2jp3C47eDBB8EIhKTun+I=
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
xorm.io/builder v0.3.5 h1:EilU39fvWDxjb1cDaELpYhsF+zziRBhew8xk4pngO+A=
xorm.io/builder v0.3.5/go.mod h1:ZFbByS/KxZI1FKRjL05PyJ4YrK2bcxlUaAxdum5aTR8=
......@@ -6,8 +6,8 @@ import (
"crawshaw.io/sqlite"
"github.com/itchio/hades"
"github.com/itchio/wharf/state"
"github.com/itchio/wharf/wtest"
"github.com/itchio/headway/state"
"github.com/itchio/hades/mtest"
)
func makeConsumer(t *testing.T) *state.Consumer {
......@@ -22,17 +22,17 @@ type WithContextFunc func(conn *sqlite.Conn, c *hades.Context)
func withContext(t *testing.T, models []interface{}, f WithContextFunc) {
dbpool, err := sqlite.Open("file:memory:?mode=memory", 0, 10)
wtest.Must(t, err)
mtest.Must(t, err)
defer dbpool.Close()
conn := dbpool.Get(context.Background().Done())
defer dbpool.Put(conn)
c, err := hades.NewContext(makeConsumer(t), models...)
wtest.Must(t, err)
mtest.Must(t, err)
c.Log = true
wtest.Must(t, c.AutoMigrate(conn))
mtest.Must(t, c.AutoMigrate(conn))
defer func() {
c.ScopeMap.Each(func(scope *hades.Scope) error {
......
......@@ -5,12 +5,12 @@ import (
"fmt"
"testing"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/stretchr/testify/assert"
"crawshaw.io/sqlite"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
)
func Test_HasMany(t *testing.T) {
......@@ -31,7 +31,7 @@ func Test_HasMany(t *testing.T) {
t.Helper()
var count int64
count, err := c.Count(conn, model, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, expectedCount, count)
}
......@@ -43,18 +43,18 @@ func Test_HasMany(t *testing.T) {
{ID: 11, Label: "Ability to not repeat oneself"},
},
}
wtest.Must(t, c.Save(conn, p1, hades.Assoc("Qualities")))
mtest.Must(t, c.Save(conn, p1, hades.Assoc("Qualities")))
assertCount(&Programmer{}, 1)
assertCount(&Quality{}, 3)
p1.Qualities[2].Label = "Inspiration again"
wtest.Must(t, c.Save(conn, p1, hades.Assoc("Qualities")))
mtest.Must(t, c.Save(conn, p1, hades.Assoc("Qualities")))
assertCount(&Programmer{}, 1)
assertCount(&Quality{}, 3)
{
q := &Quality{}
found, err := c.SelectOne(conn, q, builder.Eq{"id": 11})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
assert.EqualValues(t, "Inspiration again", q.Label)
}
......@@ -67,23 +67,23 @@ func Test_HasMany(t *testing.T) {
},
}
programmers := []*Programmer{p1, p2}
wtest.Must(t, c.Save(conn, programmers, hades.Assoc("Qualities")))
mtest.Must(t, c.Save(conn, programmers, hades.Assoc("Qualities")))
assertCount(&Programmer{}, 2)
assertCount(&Quality{}, 5)
p1bis := &Programmer{ID: 3}
wtest.Must(t, c.Preload(conn, p1bis, hades.Assoc("Qualities")))
mtest.Must(t, c.Preload(conn, p1bis, hades.Assoc("Qualities")))
assert.EqualValues(t, 3, len(p1bis.Qualities), "preload has_many")
wtest.Must(t, c.Preload(conn, p1bis, hades.Assoc("Qualities")))
mtest.Must(t, c.Preload(conn, p1bis, hades.Assoc("Qualities")))
assert.EqualValues(t, 3, len(p1bis.Qualities), "preload replaces, doesn't append")
wtest.Must(t, c.Preload(conn, p1bis,
mtest.Must(t, c.Preload(conn, p1bis,
hades.AssocWithSearch("Qualities", hades.Search{}.OrderBy("id ASC"))),
)
assert.EqualValues(t, "Inspiration", p1bis.Qualities[0].Label, "orders by (asc)")
wtest.Must(t, c.Preload(conn, p1bis,
mtest.Must(t, c.Preload(conn, p1bis,
hades.AssocWithSearch("Qualities", hades.Search{}.OrderBy("id DESC"))),
)
assert.EqualValues(t, "Inspiration again", p1bis.Qualities[0].Label, "orders by (desc)")
......
......@@ -4,9 +4,9 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -47,16 +47,16 @@ func Test_HasOne(t *testing.T) {
t.Helper()
var count int64
count, err := c.Count(conn, model, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, expectedCount, count)
}
wtest.Must(t, c.Save(conn, country, hades.OmitRoot(), hades.Assoc("Specialty", hades.Assoc("Drawback"))))
mtest.Must(t, c.Save(conn, country, hades.OmitRoot(), hades.Assoc("Specialty", hades.Assoc("Drawback"))))
assertCount(&Country{}, 0)
assertCount(&Specialty{}, 1)
assertCount(&Drawback{}, 1)
wtest.Must(t, c.Save(conn, country, hades.Assoc("Specialty", hades.Assoc("Drawback"))))
mtest.Must(t, c.Save(conn, country, hades.Assoc("Specialty", hades.Assoc("Drawback"))))
assertCount(&Country{}, 1)
assertCount(&Specialty{}, 1)
assertCount(&Drawback{}, 1)
......@@ -65,12 +65,12 @@ func Test_HasOne(t *testing.T) {
for i := 0; i < 4; i++ {
country := &Country{}
found, err := c.SelectOne(conn, country, builder.Eq{"id": 324})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
countries = append(countries, country)
}
wtest.Must(t, c.Preload(conn, countries,
mtest.Must(t, c.Preload(conn, countries,
hades.Assoc("Specialty",
hades.Assoc("Drawback"))))
})
......
......@@ -4,7 +4,7 @@ import (
"reflect"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
)
func (scope *Scope) ToEq(rec reflect.Value) builder.Eq {
......
......@@ -4,12 +4,12 @@ import (
"context"
"testing"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/stretchr/testify/assert"
"crawshaw.io/sqlite"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
)
type Language struct {
......@@ -39,13 +39,13 @@ func Test_ManyToMany(t *testing.T) {
},
}
t.Logf("saving just fr")
wtest.Must(t, c.Save(conn, fr, hades.Assoc("Words")))
mtest.Must(t, c.Save(conn, fr, hades.Assoc("Words")))
assertCount := func(model interface{}, expectedCount int64) {
t.Helper()
var count int64
count, err := c.Count(conn, model, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, expectedCount, count)
}
assertCount(&Language{}, 1)
......@@ -60,7 +60,7 @@ func Test_ManyToMany(t *testing.T) {
},
}
t.Logf("saving fr+en")
wtest.Must(t, c.Save(conn, []*Language{fr, en}, hades.Assoc("Words")))
mtest.Must(t, c.Save(conn, []*Language{fr, en}, hades.Assoc("Words")))
assertCount(&Language{}, 2)
assertCount(&Word{}, 2)
assertCount(&LanguageWord{}, 4)
......@@ -70,14 +70,14 @@ func Test_ManyToMany(t *testing.T) {
{ID: "Wreck"},
{ID: "Nervous"},
}
wtest.Must(t, c.Save(conn, []*Language{en}, hades.Assoc("Words")))
mtest.Must(t, c.Save(conn, []*Language{en}, hades.Assoc("Words")))
assertCount(&Language{}, 2)
assertCount(&Word{}, 4)
assertCount(&LanguageWord{}, 6)
t.Logf("replacing all english words")
wtest.Must(t, c.Save(conn, []*Language{en}, hades.AssocReplace("Words")))
mtest.Must(t, c.Save(conn, []*Language{en}, hades.AssocReplace("Words")))
assertCount(&Language{}, 2)
assertCount(&Word{}, 4)
......@@ -85,7 +85,7 @@ func Test_ManyToMany(t *testing.T) {
t.Logf("adding commentary")
en.Words[0].Comment = "punk band reference"
wtest.Must(t, c.Save(conn, []*Language{en}, hades.Assoc("Words")))
mtest.Must(t, c.Save(conn, []*Language{en}, hades.Assoc("Words")))
assertCount(&Language{}, 2)
assertCount(&Word{}, 4)
assertCount(&LanguageWord{}, 4)
......@@ -93,7 +93,7 @@ func Test_ManyToMany(t *testing.T) {
{
w := &Word{}
found, err := c.SelectOne(conn, w, builder.Eq{"id": "Wreck"})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
assert.EqualValues(t, "punk band reference", w.Comment)
}
......@@ -161,19 +161,19 @@ func Test_ManyToManyRevenge(t *testing.T) {
}
}
p := makeProfile()
wtest.Must(t, c.Save(conn, p,
mtest.Must(t, c.Save(conn, p,
hades.Assoc("ProfileGames",
hades.Assoc("Game"),
),
))
numPG, err := c.Count(conn, &ProfileGame{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 3, numPG)
var names []struct {
Name string
}
wtest.Must(t, c.ExecWithSearch(conn,
mtest.Must(t, c.ExecWithSearch(conn,
builder.Select("games.title").
From("games").
LeftJoin("profile_games", builder.Expr("profile_games.game_id = games.id")),
......@@ -190,13 +190,13 @@ func Test_ManyToManyRevenge(t *testing.T) {
// delete one
p.ProfileGames = p.ProfileGames[1:]
wtest.Must(t, c.Save(conn, p,
mtest.Must(t, c.Save(conn, p,
hades.AssocReplace("ProfileGames",
hades.Assoc("Game"),
),
))
numPG, err = c.Count(conn, &ProfileGame{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 2, numPG)
})
}
......
package mtest
import (
"testing"
)
// Must shows a complete error stack and fails a test immediately
// if err is non-nil
func Must(t *testing.T, err error) {
if err != nil {
t.Helper()
t.Errorf("%+v", err)
t.FailNow()
}
}
......@@ -8,9 +8,9 @@ import (
"github.com/stretchr/testify/assert"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/state"
"github.com/itchio/headway/state"
)
func Test_Null(t *testing.T) {
......
......@@ -4,7 +4,7 @@ import (
"reflect"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/pkg/errors"
)
......
......@@ -5,7 +5,7 @@ import (
"crawshaw.io/sqlite"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
)
func Test_PreloadEdgeCases(t *testing.T) {
......@@ -24,10 +24,10 @@ func Test_PreloadEdgeCases(t *testing.T) {
withContext(t, models, func(conn *sqlite.Conn, c *hades.Context) {
// non-existent Bar
f := &Foo{ID: 1, BarID: 999}
wtest.Must(t, c.Preload(conn, f, hades.Assoc("Bar")))
mtest.Must(t, c.Preload(conn, f, hades.Assoc("Bar")))
// empty slice
var foos []*Foo
wtest.Must(t, c.Preload(conn, foos, hades.Assoc("Bar")))
mtest.Must(t, c.Preload(conn, foos, hades.Assoc("Bar")))
})
}
......@@ -5,7 +5,7 @@ import (
"crawshaw.io/sqlite"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
)
func Test_Save(t *testing.T) {
......@@ -34,6 +34,6 @@ func Test_Save(t *testing.T) {
p := &Profile{
ID: 1,
}
wtest.Must(t, c.Save(conn, p))
mtest.Must(t, c.Save(conn, p))
})
}
......@@ -4,9 +4,9 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/wtest"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -28,7 +28,7 @@ func Test_Scan(t *testing.T) {
&GameEmbedData{},
}
withContext(t, models, func(conn *sqlite.Conn, c *hades.Context) {
wtest.Must(t, c.Save(conn, []*Game{
mtest.Must(t, c.Save(conn, []*Game{
&Game{
ID: 24,
Title: "Jazz Jackrabbit",
......@@ -51,7 +51,7 @@ func Test_Scan(t *testing.T) {
Game `hades:"squash"`
GameEmbedData `hades:"squash"`
}
wtest.Must(t, c.ExecWithSearch(conn,
mtest.Must(t, c.ExecWithSearch(conn,
builder.Select("games.*", "game_embed_data.*").
From("games").
LeftJoin("game_embed_data", builder.Expr("game_embed_data.game_id = games.id")),
......
......@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/go-xorm/builder"
"xorm.io/builder"
)
type join struct {
......
......@@ -5,7 +5,7 @@ import (
"reflect"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/pkg/errors"
)
......
......@@ -5,10 +5,10 @@ import (
"testing"
"crawshaw.io/sqlite"
"github.com/go-xorm/builder"
"xorm.io/builder"
"github.com/itchio/hades"
"github.com/itchio/wharf/state"
"github.com/itchio/wharf/wtest"
"github.com/itchio/headway/state"
"github.com/itchio/hades/mtest"
"github.com/stretchr/testify/assert"
)
......@@ -43,7 +43,7 @@ func Test_Select(t *testing.T) {
conn := dbpool.Get(context.Background().Done())
defer dbpool.Put(conn)
wtest.Must(t, c.ExecRaw(conn, "CREATE TABLE honors (id INTEGER PRIMARY KEY, title TEXT)", nil))
mtest.Must(t, c.ExecRaw(conn, "CREATE TABLE honors (id INTEGER PRIMARY KEY, title TEXT)", nil))
baseHonors := []Honor{
{ID: 0, Title: "Best Picture"},
......@@ -53,23 +53,23 @@ func Test_Select(t *testing.T) {
}
for _, h := range baseHonors {
wtest.Must(t, c.Exec(conn, builder.Insert(builder.Eq{"id": h.ID, "title": h.Title}).Into("honors"), nil))
mtest.Must(t, c.Exec(conn, builder.Insert(builder.Eq{"id": h.ID, "title": h.Title}).Into("honors"), nil))
}
count, err := c.Count(conn, &Honor{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 4, count)
honor := &Honor{}
found, err := c.SelectOne(conn, honor, builder.Eq{"id": 3})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
var honors []*Honor
wtest.Must(t, c.Select(conn, &honors, builder.Gte{"id": 2}, hades.Search{}))
mtest.Must(t, c.Select(conn, &honors, builder.Gte{"id": 2}, hades.Search{}))
assert.EqualValues(t, 2, len(honors))
wtest.Must(t, c.ExecRaw(conn, "DROP TABLE honors", nil))
mtest.Must(t, c.ExecRaw(conn, "DROP TABLE honors", nil))
// ---------
......@@ -141,7 +141,7 @@ func Test_SelectSquashed(t *testing.T) {
conn := dbpool.Get(context.Background().Done())
defer dbpool.Put(conn)
wtest.Must(t, c.ExecRaw(conn, "CREATE TABLE androids (id INTEGER PRIMARY KEY, wise BOOLEAN, funny BOOLEAN)", nil))
mtest.Must(t, c.ExecRaw(conn, "CREATE TABLE androids (id INTEGER PRIMARY KEY, wise BOOLEAN, funny BOOLEAN)", nil))
defer c.ExecRaw(conn, "DROP TABLE androids", nil)
baseAndroids := []Android{
......@@ -152,16 +152,16 @@ func Test_SelectSquashed(t *testing.T) {
}
for _, a := range baseAndroids {
wtest.Must(t, c.Exec(conn, builder.Insert(builder.Eq{"id": a.ID, "wise": a.Traits.Wise, "funny": a.Traits.Funny}).Into("androids"), nil))
mtest.Must(t, c.Exec(conn, builder.Insert(builder.Eq{"id": a.ID, "wise": a.Traits.Wise, "funny": a.Traits.Funny}).Into("androids"), nil))
}
count, err := c.Count(conn, &Android{}, builder.NewCond())
wtest.Must(t, err)
mtest.Must(t, err)
assert.EqualValues(t, 4, count)
a := &Android{}
found, err := c.SelectOne(conn, a, builder.Eq{"id": 1})
wtest.Must(t, err)
mtest.Must(t, err)
assert.True(t, found)
assert.EqualValues(t, baseAndroids[0], *a)
}