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

36 lines
415 B
Go
Raw Normal View History

package resync_test
import (
"testing"
"github.com/cheekybits/is"
2016-03-01 00:51:26 +00:00
"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)
}