Skip to content

Commit

Permalink
test ttl expire column has default current_timestamp property
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiXinChan committed Oct 12, 2023
1 parent 85f2abe commit 178904d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/ttl/ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import (

const (
testTTLTableName = "test_ttl"
testTTLCreateStatement = "create table if not exists test_ttl(c1 int(12) primary key, c2 int(12), c3 timestamp(6)) TTL(c3 + INTERVAL 2 second);"
testTTLCreateStatement = "create table if not exists test_ttl(c1 int(12) primary key, c2 int(12), c3 timestamp default current_timestamp on update current_timestamp) TTL(c3 + INTERVAL 2 second);"
)

const (
passTTLTest = true
passTTLTest = false
)

func TestTTL_insert(t *testing.T) {
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestTTL_replace(t *testing.T) {

time.Sleep(2 * time.Second)

// 3. replace, expired, replace successfully, affectRows = 1
// 3. replace, expired, replace successfully, affectRows = 2
ctx, _ = context.WithTimeout(context.Background(), 1000*time.Second) // 10s
rowKey = []*table.Column{table.NewColumn("c1", int32(0))}
mutateColumns = []*table.Column{table.NewColumn("c2", int32(2)), table.NewColumn("c3", table.TimeStamp(time.Now().Local()))}
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestTTL_insertUp(t *testing.T) {

// 1. insertUp(insert)
rowKey := []*table.Column{table.NewColumn("c1", int32(0))}
mutateColumns := []*table.Column{table.NewColumn("c2", int32(0)), table.NewColumn("c3", table.TimeStamp(time.Now().Local()))}
mutateColumns := []*table.Column{table.NewColumn("c2", int32(0))}
affectRows, err := cli.InsertOrUpdate(
context.TODO(),
tableName,
Expand All @@ -316,7 +316,7 @@ func TestTTL_insertUp(t *testing.T) {
// 2. insertUp(insert), not expired, update
ctx, _ := context.WithTimeout(context.Background(), 1000*time.Second) // 10s
rowKey = []*table.Column{table.NewColumn("c1", int32(0))}
mutateColumns = []*table.Column{table.NewColumn("c2", int32(1)), table.NewColumn("c3", table.TimeStamp(time.Now().Local()))}
mutateColumns = []*table.Column{table.NewColumn("c2", int32(1))}
affectRows, err = cli.InsertOrUpdate(
ctx,
tableName,
Expand All @@ -331,7 +331,7 @@ func TestTTL_insertUp(t *testing.T) {
// 3. insertUp(insert), expired, delete expired, insert new, success
ctx, _ = context.WithTimeout(context.Background(), 1000*time.Second) // 10s
rowKey = []*table.Column{table.NewColumn("c1", int32(0))}
mutateColumns = []*table.Column{table.NewColumn("c2", int32(2)), table.NewColumn("c3", table.TimeStamp(time.Now().Local()))}
mutateColumns = []*table.Column{table.NewColumn("c2", int32(2))}
affectRows, err = cli.InsertOrUpdate(
ctx,
tableName,
Expand Down

0 comments on commit 178904d

Please sign in to comment.