Fix IsAborted() method
This commit is contained in:
parent
4cc2de6207
commit
74f5051cb5
@ -93,7 +93,7 @@ func (c *Context) Next() {
|
|||||||
|
|
||||||
// Returns if the currect context was aborted.
|
// Returns if the currect context was aborted.
|
||||||
func (c *Context) IsAborted() bool {
|
func (c *Context) IsAborted() bool {
|
||||||
return c.index == AbortIndex
|
return c.index >= AbortIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stops the system to continue calling the pending handlers in the chain.
|
// Stops the system to continue calling the pending handlers in the chain.
|
||||||
|
@ -408,6 +408,20 @@ func TestContextNegotiationFormatCustum(t *testing.T) {
|
|||||||
assert.Equal(t, c.NegotiateFormat(MIMEJSON), MIMEJSON)
|
assert.Equal(t, c.NegotiateFormat(MIMEJSON), MIMEJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContextIsAborted(t *testing.T) {
|
||||||
|
c, _, _ := createTestContext()
|
||||||
|
|
||||||
|
assert.False(t, c.IsAborted())
|
||||||
|
|
||||||
|
c.Abort()
|
||||||
|
|
||||||
|
assert.True(t, c.IsAborted())
|
||||||
|
|
||||||
|
c.index += 1
|
||||||
|
|
||||||
|
assert.True(t, c.IsAborted())
|
||||||
|
}
|
||||||
|
|
||||||
// TestContextData tests that the response can be written from `bytesting`
|
// TestContextData tests that the response can be written from `bytesting`
|
||||||
// with specified MIME type
|
// with specified MIME type
|
||||||
func TestContextAbortWithStatus(t *testing.T) {
|
func TestContextAbortWithStatus(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user