buffalo: Truncate for "buffalo test" is not working on cockroach v2.0.6
Description
When executing “buffalo test” with a configured cockroachDB v2.0.6 the data will not get truncated after each test. The Buffalo Auth Plugin generates multiple tests to be sure the user object is not already saved in the database before testing some logic. If I execute one test it will pass, with executing the test suite most will fail. If I run the same tests on a cockroachDB v1.1.9 everything works all fine.
Steps to Reproduce the Problem
Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the curl command you used, that sort of thing.
- Create a new project with “buffalo new coke --db-type cockroach”
- Make sure the Cockroach DB is running.
- Generate authentication with the buffalo auth plugin
- Create databases with “buffalo db create -a”
- Run tests(“buffalo test”), some of them will fail because they expect the database to be empty.
- Configure a postgre database with “buffalo db g config”
- Create databases with “buffalo db create -a”
- Run tests(“buffalo test”), the tests pass all
Expected Behavior
After each test the cockroach database should truncate the created rows.
Actual Behavior
After each test the cockroach database keeps the data.
Info
### Buffalo Version
v0.13.2
### App Information
Pwd=/Users/dorus/go/src/github.com/edudorus/asom
Root=/Users/dorus/go/src/github.com/edudorus/asom
GoPath=/Users/dorus/go
Name=asom
Bin=bin/asom
PackagePkg=github.com/edudorus/asom
ActionsPkg=github.com/edudorus/asom/actions
ModelsPkg=github.com/edudorus/asom/models
GriftsPkg=github.com/edudorus/asom/grifts
VCS=git
WithPop=true
WithSQLite=false
WithDep=false
WithWebpack=true
WithYarn=false
WithDocker=true
WithGrifts=true
WithModules=false
### Go Version
go version go1.11.1 darwin/amd64
### Go Env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dorus/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dorus/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_5/7c3lr50s2wzgmw_y31t1r6400000gn/T/go-build684181983=/tmp/go-build -gno-record-gcc-switches -fno-common"
### Node Version
v11.0.0
### NPM Version
6.4.1
### Yarn Version
Yarn Not Found
### PostgreSQL Version
pg_ctl (PostgreSQL) 10.5
### MySQL Version
mysql Ver 8.0.12 for osx10.14 on x86_64 (Homebrew)
### SQLite Version
3.24.0 2018-06-04 14:10:15 95fbac39baaab1c3a84fdfc82ccb7f42398b2e92f18a2a57bce1d4a713cbaapl
### Dep Version
could not find a Gopkg.toml file
### Dep Status
could not find a Gopkg.toml file
### go.mod
module github.com/edudorus/asom
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (11 by maintainers)
@sio4 I just run my tests successfully with the PR that was merged int the development branch. I reset the pool size to 5 and I have around 30 tests. Everything works fine so I will close this issue. Thanks for the help 👍
Oops! I tested with a small app for test and I confirmed. Is that test case 5th test? maybe? Can you test that again with database configuration parameter
pool: 4orpool:5? Just for confirmation. Please let me know.I think that the problem is probably
TruncateAll()holds connection pool and not release it. I will check the flow.Hi @eduDorus, thanks for providing details.
First, I misunderstood your meaning of “each test”. I just understood it as each test running by
buffalo testbut now I understood more clearly you mean every single test cases. Ok, you are right. Tables should be truncated before running each test cases.Second, you found a bug on the
TruncateAll()of cockroach dialect of pop and I tested with a quick fix to solve this problem. Anyway, since I am not sure how can I make it more secure (since we run the test withrootfor some bad reason,) and compatible with differences between versions, I will check more tomorrow and will make a PR for this issue. (if someone does not fix it then.)