mirror of https://github.com/status-im/consul.git
ae: add test for ifNotPausedRun
This commit is contained in:
parent
11e172d1e9
commit
92088d21e8
|
@ -1,7 +1,9 @@
|
|||
package ae
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -56,3 +58,22 @@ func TestAE_nestedPauseResume(t *testing.T) {
|
|||
}()
|
||||
l.Resume()
|
||||
}
|
||||
|
||||
func TestAE_ifNotPausedRun(t *testing.T) {
|
||||
l := NewStateSyner(nil, 0, nil, nil)
|
||||
|
||||
errCalled := errors.New("f called")
|
||||
f := func() error { return errCalled }
|
||||
|
||||
l.Pause()
|
||||
err := l.ifNotPausedRun(f)
|
||||
if got, want := err, errPaused; !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got error %q want %q", got, want)
|
||||
}
|
||||
l.Resume()
|
||||
|
||||
err = l.ifNotPausedRun(f)
|
||||
if got, want := err, errCalled; got != want {
|
||||
t.Fatalf("got error %q want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue