Skip to content

Commit

Permalink
server: improve test coverage of server/conn.go (pingcap#13712)
Browse files Browse the repository at this point in the history
  • Loading branch information
reafans authored and sre-bot committed Nov 25, 2019
1 parent ffa8057 commit 74bb0d5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,28 @@ func (ts *ConnTestSuite) TestShutDown(c *C) {
c.Assert(err, Equals, executor.ErrQueryInterrupted)
c.Assert(rs.closed, Equals, int32(1))
}

func (ts *ConnTestSuite) TestShutdownOrNotify(c *C) {
c.Parallel()
se, err := session.CreateSession4Test(ts.store)
c.Assert(err, IsNil)
tc := &TiDBContext{
session: se,
stmts: make(map[int]*TiDBStatement),
}
cc := &clientConn{
connectionID: 1,
server: &Server{
capability: defaultCapability,
},
status: connStatusWaitShutdown,
ctx: tc,
}
c.Assert(cc.ShutdownOrNotify(), IsFalse)
cc.status = connStatusReading
c.Assert(cc.ShutdownOrNotify(), IsTrue)
c.Assert(cc.status, Equals, connStatusShutdown)
cc.status = connStatusDispatching
c.Assert(cc.ShutdownOrNotify(), IsFalse)
c.Assert(cc.status, Equals, connStatusWaitShutdown)
}

0 comments on commit 74bb0d5

Please sign in to comment.