Skip to content

Commit bb2bab7

Browse files
committed
tests: select testdb and use MySQL 8.0 by default
Without the `USE...` in `TestExecuteMultiple` the test panics as the result in `conn_test.go:108` is nil. ``` $ go test ---------------------------------------------------------------------- PANIC: conn_test.go:92: connTestSuite.TestExecuteMultiple ... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x438592) /usr/lib/golang/src/runtime/panic.go:884 in gopanic /usr/lib/golang/src/runtime/panic.go:260 in panicmem /usr/lib/golang/src/runtime/signal_unix.go:837 in sigpanic conn_test.go:108 in connTestSuite.TestExecuteMultiple.func1 conn.go:273 in Conn.ExecuteMultiple conn_test.go:101 in connTestSuite.TestExecuteMultiple /usr/lib/golang/src/reflect/value.go:370 in Value.Call /home/dvaneeden/go/pkg/mod/github.com/pingcap/[email protected]/check.go:836 in suiteRunner.forkTest.func1 /home/dvaneeden/go/pkg/mod/github.com/pingcap/[email protected]/check.go:730 in suiteRunner.forkCall.func1 /usr/lib/golang/src/runtime/asm_amd64.s:1598 in goexit ---------------------------------------------------------------------- FAIL: conn_test.go:132: connTestSuite.TestExecuteSelectStreaming conn_test.go:170: c.Assert(err, IsNil) ... value *mysql.MyError = &mysql.MyError{Code:0x416, Message:"No database selected", State:"3D000"} ("ERROR 1046 (3D000): No database selected") ---------------------------------------------------------------------- FAIL: conn_test.go:86: connTestSuite.TestFieldList conn_test.go:88: c.Assert(err, IsNil) ... value *mysql.MyError = &mysql.MyError{Code:0x416, Message:"No database selected", State:"3D000"} ("ERROR 1046 (3D000): No database selected") ---------------------------------------------------------------------- FAIL: conn_test.go:38: connTestSuite.TearDownSuite conn_test.go:43: s.testExecute_DropTable(c) conn_test.go:83: c.Assert(err, IsNil) ... value *mysql.MyError = &mysql.MyError{Code:0x416, Message:"No database selected", State:"3D000"} ("ERROR 1046 (3D000): No database selected") OOPS: 18 passed, 3 FAILED, 1 PANICKED --- FAIL: Test (0.46s) FAIL exit status 1 FAIL github.com/go-mysql-org/go-mysql/client 0.465s ```
1 parent 77430c6 commit bb2bab7

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build:
1111
test:
1212
go test --race -timeout 2m ./...
1313

14-
MYSQL_VERSION ?= 5.7
14+
MYSQL_VERSION ?= 8.0
1515
test-local:
1616
docker run --rm -d --network=host --name go-mysql-server \
1717
-e MYSQL_ALLOW_EMPTY_PASSWORD=true \

client/conn_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ func (s *connTestSuite) TestExecuteMultiple(c *C) {
9797
`THIS IS BOGUS()`,
9898
}
9999

100+
_, err := s.c.Execute("USE " + *testDB)
101+
c.Assert(err, IsNil)
102+
100103
count := 0
101104
result, err := s.c.ExecuteMultiple(strings.Join(queries, "; "), func(result *mysql.Result, err error) {
102105
switch count {

docker/resources/waitfor.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ port=$2
44

55
echo "Waiting for mysql at $host:$port"
66
while true; do
7-
docker run --rm -it --network=host mysql:5.7 mysql -h$host -P$port -e "SELECT RAND()" >/dev/null
7+
docker run --rm -it --network=host mysql:8.0 mysql -h$host -P$port -e "SELECT RAND()" >/dev/null
88
if [[ $? -eq 0 ]]; then
99
echo 'Connected'
1010
break

0 commit comments

Comments
 (0)