Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions tester/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func WithHeaders(headers goka.Headers) EmitOption {
}

// WithTime causes the tester to emit the message with passed timestamp.
// default is time.Now()
// default is a zero timestamp
func WithTime(time time.Time) EmitOption {
return func(opts *emitOption) {
opts.time = time
Expand Down Expand Up @@ -160,9 +160,7 @@ func (tt *Tester) EmitterProducerBuilder() goka.ProducerBuilder {
// This takes care of queueing calls
// to handled topics or putting the emitted messages in the emitted-messages-list
func (tt *Tester) handleEmit(topic string, key string, value []byte, options ...EmitOption) *goka.Promise {
opts := &emitOption{
time: time.Now(),
}
opts := new(emitOption)
opts.applyOptions(options...)
_, finisher := goka.NewPromiseWithFinisher()

Expand Down Expand Up @@ -418,9 +416,7 @@ func (tt *Tester) GetTableKeys(table goka.Table) []string {
func (tt *Tester) Consume(topic string, key string, msg interface{}, options ...EmitOption) {
tt.waitStartup()

opts := &emitOption{
time: time.Now(),
}
opts := new(emitOption)
opts.applyOptions(options...)
value := reflect.ValueOf(msg)
if msg == nil || (value.Kind() == reflect.Ptr && value.IsNil()) {
Expand Down
2 changes: 1 addition & 1 deletion tester/tester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestTesterConsume(t *testing.T) {
require.EqualValues(t, "some-key", key)
require.EqualValues(t, "value", value)
// the test should not take longer than 1 second
require.Truef(t, time.Since(timestamp).Seconds() < 1, "expected roughly %v, got %v", time.Now(), timestamp)
require.True(t, timestamp.IsZero())

// consume with timestamp option
gkt.Consume("input", "anotherkey", "value", WithTime(time.Unix(123, 0)))
Expand Down