ae: add test for ifNotPausedRun

This commit is contained in:
Frank Schroeder 2017-10-19 11:12:29 +02:00
parent 4f79ee3188
commit 6de645a8b8
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
1 changed files with 21 additions and 0 deletions

View File

@ -1,7 +1,9 @@
package ae package ae
import ( import (
"errors"
"fmt" "fmt"
"reflect"
"testing" "testing"
) )
@ -56,3 +58,22 @@ func TestAE_nestedPauseResume(t *testing.T) {
}() }()
l.Resume() 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)
}
}