This commit is contained in:
Родитель
693cc78601
Коммит
f82643d9c4
|
@ -490,4 +490,4 @@ func getOffsetExpression(checkpoint persist.Checkpoint) string {
|
|||
// offset based, non-inclusive
|
||||
// ex: "amqp.annotation.x-opt-offset > '100'"
|
||||
return fmt.Sprintf(amqpAnnotationFormat, offsetAnnotationName, "", checkpoint.Offset)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,27 +8,27 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetOffsetExpression(t * testing.T) {
|
||||
expr := getOffsetExpression(persist.NewCheckpointFromStartOfStream())
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '-1'", expr)
|
||||
func TestGetOffsetExpression(t *testing.T) {
|
||||
expr := getOffsetExpression(persist.NewCheckpointFromStartOfStream())
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '-1'", expr)
|
||||
|
||||
expr = getOffsetExpression(persist.NewCheckpointFromEndOfStream())
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '@latest'", expr)
|
||||
expr = getOffsetExpression(persist.NewCheckpointFromEndOfStream())
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '@latest'", expr)
|
||||
|
||||
expr = getOffsetExpression(persist.Checkpoint{Offset: "100"})
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '100'", expr)
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '100'", expr)
|
||||
|
||||
// offset wins - the time is ignored if they've specified an offset in the checkpoint.t
|
||||
now, err := time.Parse(time.RFC3339, "1975-04-04T01:02:03Z")
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
||||
// now's ignored here - the offset will win.
|
||||
checkpoint := persist.NewCheckpoint("100", 1, now)
|
||||
expr = getOffsetExpression(checkpoint)
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '100'", expr)
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-offset > '100'", expr)
|
||||
|
||||
// no offset this time, date will be used
|
||||
checkpoint = persist.NewCheckpoint("", 1, now)
|
||||
expr = getOffsetExpression(checkpoint)
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-enqueued-time > '165805323000'", expr)
|
||||
}
|
||||
assert.EqualValues(t, "amqp.annotation.x-opt-enqueued-time > '165805323000'", expr)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче