New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table(test): add unit tests for coverage of package table #3770

Merged
merged 7 commits into from Jul 21, 2017

Conversation

Projects
None yet
3 participants
@jackysp
Member

jackysp commented Jul 17, 2017

Coverage of package table to 80%.
PTAL @shenli @zimulala

Show outdated Hide outdated table/table_test.go
@@ -0,0 +1,72 @@
// Copyright 2016 PingCAP, Inc.

This comment has been minimized.

@shenli

shenli Jul 17, 2017

Member

2016->2017

@shenli

shenli Jul 17, 2017

Member

2016->2017

This comment has been minimized.

@jackysp

jackysp Jul 17, 2017

Member

Done.

@jackysp

jackysp Jul 17, 2017

Member

Done.

Show outdated Hide outdated table/table_test.go
"github.com/pingcap/tidb/util/testleak"
)
var _ = Suite(&testSuite{})

This comment has been minimized.

@shenli

shenli Jul 17, 2017

Member

We should use only one suit in a package.

@shenli

shenli Jul 17, 2017

Member

We should use only one suit in a package.

This comment has been minimized.

@jackysp

jackysp Jul 17, 2017

Member

Done.

@jackysp

jackysp Jul 17, 2017

Member

Done.

@jackysp

This comment has been minimized.

Show comment
Hide comment
@jackysp

jackysp Jul 17, 2017

Member

Tests are simplified, PTAL @shenli

Member

jackysp commented Jul 17, 2017

Tests are simplified, PTAL @shenli

@@ -92,10 +111,13 @@ func (ts *testMemoryTableSuite) TestMemoryBasic(c *C) {
c.Assert(row[0].GetInt64(), Equals, int64(1))
_, err = tb.AddRecord(ctx, types.MakeDatums(1, "aba"))
c.Assert(err, IsNil)
c.Assert(err, NotNil)

This comment has been minimized.

@shenli

shenli Jul 18, 2017

Member

Why this is change?

@shenli

shenli Jul 18, 2017

Member

Why this is change?

This comment has been minimized.

@jackysp

jackysp Jul 19, 2017

Member

The first column turns to be the primary key on line 68 and 70, so primary key conflicts here.

@jackysp

jackysp Jul 19, 2017

Member

The first column turns to be the primary key on line 68 and 70, so primary key conflicts here.

This comment has been minimized.

@shenli

shenli Jul 20, 2017

Member

Got it.

@shenli

shenli Jul 20, 2017

Member

Got it.

Show outdated Hide outdated table/tables/tables.go
@@ -706,6 +706,9 @@ func (t *Table) RebaseAutoID(newBase int64, isSetStep bool) error {
// Seek implements table.Table Seek interface.
func (t *Table) Seek(ctx context.Context, h int64) (int64, bool, error) {
seekKey := tablecodec.EncodeRowKeyWithHandle(t.ID, h)
if ctx == nil {

This comment has been minimized.

@shenli

shenli Jul 18, 2017

Member

ctx should never be nil.

@shenli

shenli Jul 18, 2017

Member

ctx should never be nil.

This comment has been minimized.

@jackysp

jackysp Jul 19, 2017

Member

Ok, removed.

@jackysp

jackysp Jul 19, 2017

Member

Ok, removed.

Show outdated Hide outdated table/tables/tables_test.go
c.Assert(err, NotNil)
tbInfo.State = model.StateNone
tables.TableFromMeta(nil, tbInfo)
c.Assert(tb, IsNil)

This comment has been minimized.

@shenli

shenli Jul 18, 2017

Member

tb and err are not changed after line 322. Why check them again?

@shenli

shenli Jul 18, 2017

Member

tb and err are not changed after line 322. Why check them again?

This comment has been minimized.

@jackysp

jackysp Jul 19, 2017

Member

Add return values of line 324. The last two checks will work.

@jackysp

jackysp Jul 19, 2017

Member

Add return values of line 324. The last two checks will work.

@@ -92,10 +111,13 @@ func (ts *testMemoryTableSuite) TestMemoryBasic(c *C) {
c.Assert(row[0].GetInt64(), Equals, int64(1))
_, err = tb.AddRecord(ctx, types.MakeDatums(1, "aba"))
c.Assert(err, IsNil)
c.Assert(err, NotNil)

This comment has been minimized.

@shenli

shenli Jul 20, 2017

Member

Got it.

@shenli

shenli Jul 20, 2017

Member

Got it.

@tiancaiamao

LGTM

}
val, err = CastValue(ctx, types.NewDatum("test"), &colInfoS)
c.Assert(err, IsNil)
c.Assert(val, NotNil)

This comment has been minimized.

@tiancaiamao

tiancaiamao Jul 21, 2017

Contributor

CastValue return types.Datum, so val would never be Nil, this line is useless.

@tiancaiamao

tiancaiamao Jul 21, 2017

Contributor

CastValue return types.Datum, so val would never be Nil, this line is useless.

@tiancaiamao tiancaiamao merged commit b091e82 into master Jul 21, 2017

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@tiancaiamao tiancaiamao deleted the yusp/unit_test_table branch Jul 21, 2017

dbjoa added a commit to cloud-pi/tidb that referenced this pull request Jul 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment