Browse Source

add TestWaitDBUp

pull/55/head
yedf2 4 years ago
parent
commit
7d465f6356
  1. 3
      common/types.go
  2. 4
      common/types_test.go

3
common/types.go

@ -197,6 +197,9 @@ func checkConfig() string {
func WaitDBUp() {
sdb, err := dtmimp.StandaloneDB(DtmConfig.DB)
dtmimp.FatalIfError(err)
defer func() {
sdb.Close()
}()
for _, err := dtmimp.DBExec(sdb, "select 1"); err != nil; { // wait for mysql to start
time.Sleep(3 * time.Second)
_, err = dtmimp.DBExec(sdb, "select 1")

4
common/types_test.go

@ -19,6 +19,10 @@ func TestDb(t *testing.T) {
assert.NotEqual(t, nil, err)
}
func TestWaitDBUp(t *testing.T) {
WaitDBUp()
}
func TestDbAlone(t *testing.T) {
db, err := dtmimp.StandaloneDB(DtmConfig.DB)
assert.Nil(t, err)

Loading…
Cancel
Save