From 74f5051cb56072eaf634b05a6e7db2a779781826 Mon Sep 17 00:00:00 2001 From: Adam Dratwinski Date: Thu, 2 Jul 2015 13:27:22 +0200 Subject: [PATCH] Fix IsAborted() method --- context.go | 2 +- context_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 12920fd..49c7021 100644 --- a/context.go +++ b/context.go @@ -93,7 +93,7 @@ func (c *Context) Next() { // Returns if the currect context was aborted. 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. diff --git a/context_test.go b/context_test.go index 9b78992..56c71c7 100644 --- a/context_test.go +++ b/context_test.go @@ -408,6 +408,20 @@ func TestContextNegotiationFormatCustum(t *testing.T) { 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` // with specified MIME type func TestContextAbortWithStatus(t *testing.T) {