Skip to content

Commit 11ff5eb

Browse files
authored
Merge pull request #484 from lovoo/revert-tester-default-timestamp
set tester default context timestamp to zero
2 parents 4f868b8 + 7319e13 commit 11ff5eb

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

tester/tester.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func WithHeaders(headers goka.Headers) EmitOption {
2929
}
3030

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

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

421-
opts := &emitOption{
422-
time: time.Now(),
423-
}
419+
opts := new(emitOption)
424420
opts.applyOptions(options...)
425421
value := reflect.ValueOf(msg)
426422
if msg == nil || (value.Kind() == reflect.Ptr && value.IsNil()) {

tester/tester_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestTesterConsume(t *testing.T) {
7070
require.EqualValues(t, "some-key", key)
7171
require.EqualValues(t, "value", value)
7272
// the test should not take longer than 1 second
73-
require.Truef(t, time.Since(timestamp).Seconds() < 1, "expected roughly %v, got %v", time.Now(), timestamp)
73+
require.True(t, timestamp.IsZero())
7474

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

0 commit comments

Comments
 (0)