go-rel / reltest Goto Github PK
View Code? Open in Web Editor NEWDatabase unit testing for Golang
License: MIT License
Database unit testing for Golang
License: MIT License
I see that go-rel/reltest
is not merely relocated lines of code from go-rel/rel/reltest
. One thing I still find it confusing is the feature I mentioned on the title is no longer supported in go-rel/reltest
. For example, test below (slightly modified from repository_test.go
) will pass on go-rel/rel/reltest
but fail on go-rel/reltest
func TestRepository_Transaction_error(t *testing.T) {
var (
repo = New()
result = Book{Title: "Golang for dummies"}
book = Book{ID: 1, Title: "Golang for dummies"}
)
repo.ExpectTransaction(func(repo *Repository) {
repo.ExpectInsert()
repo.ExpectUpdate()
repo.ExpectUpdate().ConnectionClosed()
})
assert.Equal(t, sql.ErrConnDone, repo.Transaction(context.TODO(), func(ctx context.Context) error {
if err := repo.Insert(ctx, &result); err != nil {
return err
}
if err := repo.Update(ctx, &result); err != nil {
return err
}
return repo.Update(ctx, &result)
}))
assert.Equal(t, book, result)
repo.AssertExpectations(t)
}
Is there any suggestion how to refactor above test to pass on go-rel/reltest
as well? Thank you
// this work
repo.ExpectDelete().For(&Book{ID: 1}).Success()
// this doesn't work, but it should
repo.ExpectDelete().For(Book{ID: 1}).Success()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.