-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from Shopify/better_offset_range_handling
Consumer: check offset before returning ConsumePartition.
- Loading branch information
Showing
4 changed files
with
179 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package sarama | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
) | ||
|
||
func TestFuncConsumerOffsetOutOfRange(t *testing.T) { | ||
checkKafkaAvailability(t) | ||
|
||
consumer, err := NewConsumer(kafkaBrokers, nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if _, err := consumer.ConsumePartition("single_partition", 0, -10); err != ErrOffsetOutOfRange { | ||
t.Error("Expected ErrOffsetOutOfRange, got:", err) | ||
} | ||
|
||
if _, err := consumer.ConsumePartition("single_partition", 0, math.MaxInt64); err != ErrOffsetOutOfRange { | ||
t.Error("Expected ErrOffsetOutOfRange, got:", err) | ||
} | ||
|
||
safeClose(t, consumer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters