Skip to content

Commit

Permalink
add ts case
Browse files Browse the repository at this point in the history
Signed-off-by: okJiang <[email protected]>
  • Loading branch information
okJiang committed Oct 21, 2024
1 parent cd64c93 commit 2da7687
Showing 1 changed file with 42 additions and 23 deletions.
65 changes: 42 additions & 23 deletions tests/integrations/realcluster/ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,45 @@

package realcluster

// func TestTS(t *testing.T) {
// re := require.New(t)

// db := OpenTestDB(t)
// db.MustExec("use test")
// db.MustExec("drop table if exists t")
// db.MustExec("create table t(a int, index i(a))")
// db.MustExec("insert t values (1), (2), (3)")
// var rows int
// err := db.inner.Raw("select count(*) from t").Row().Scan(&rows)
// re.NoError(err)
// re.Equal(3, rows)

// re.NoError(err)
// re.Equal(3, rows)

// var ts uint64
// err = db.inner.Begin().Raw("select @@tidb_current_ts").Scan(&ts).Rollback().Error
// re.NoError(err)
// re.NotEqual(0, GetTimeFromTS(ts))

// db.MustClose()
// }
import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

type tsSuite struct {
realClusterSuite
}

func TestTS(t *testing.T) {
suite.Run(t, &tsSuite{
realClusterSuite: realClusterSuite{
suiteName: "ts",
},
})
}

func (s *tsSuite) TestTS() {
re := require.New(s.T())

db := OpenTestDB(s.T())
db.MustExec("use test")
db.MustExec("drop table if exists t")
db.MustExec("create table t(a int, index i(a))")
db.MustExec("insert t values (1), (2), (3)")
var rows int
err := db.inner.Raw("select count(*) from t").Row().Scan(&rows)
re.NoError(err)
re.Equal(3, rows)

re.NoError(err)
re.Equal(3, rows)

var ts uint64
err = db.inner.Begin().Raw("select @@tidb_current_ts").Scan(&ts).Rollback().Error
re.NoError(err)
re.NotEqual(0, GetTimeFromTS(ts))

db.MustClose()
}

0 comments on commit 2da7687

Please sign in to comment.