Skip to content

mock TickerFunc allows more than one function call at a time #6

Closed
@spikecurtis

Description

@spikecurtis

The real implementation of ticker func looks like this:

func (t *realContextTicker) run() {
	defer t.tkr.Stop()
	for {
		select {
		case <-t.ctx.Done():
			t.err <- t.ctx.Err()
			return
		case <-t.tkr.C:
			err := t.f()
			if err != nil {
				t.err <- err
				return
			}
		}
	}
}

This means that only one call to t.f() can occur at at time, no matter how long it takes. (The underlying ticker chan drops excess ticks.)

In contrast, the mock implementation will run t.f() multiple times in parallel if you advance the clock across multiple ticks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions