dispatch/vendor/github.com/matryer/resync/once_test.go

36 lines
415 B
Go

package resync_test
import (
"testing"
"github.com/cheekybits/is"
"github.com/matryer/resync"
)
func TestOnceReset(t *testing.T) {
is := is.New(t)
var calls int
var c resync.Once
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
is.Equal(calls, 1)
c.Reset()
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
is.Equal(calls, 2)
}