damccorm commented on a change in pull request #16980:
URL: https://github.com/apache/beam/pull/16980#discussion_r820781956
##########
File path: sdks/go/pkg/beam/core/runtime/exec/fn_test.go
##########
@@ -195,6 +196,50 @@ func TestInvoke(t *testing.T) {
}
}
+func TestRegisterCallback(t *testing.T) {
+ bf := bundleFinalizer{
+ callbacks: []bundleFinalizationCallback{},
+ lastValidCallback: time.Now(),
+ }
+ testVar := 0
+ bf.RegisterCallback(500*time.Minute, func() error {
+ testVar += 5
+ return nil
+ })
+ bf.RegisterCallback(2*time.Minute, func() error {
+ testVar = 25
+ return nil
+ })
+ callbackErr := errors.New("Callback error")
+ bf.RegisterCallback(2*time.Minute, func() error {
+ return callbackErr
+ })
+
+ // We can't do exact equality since this relies on real time, we'll
give it a broad range
+ if bf.lastValidCallback.Before(time.Now().Add(400*time.Minute)) ||
bf.lastValidCallback.After(time.Now().Add(600*time.Minute)) {
+ t.Errorf("RegisterCallback() lastValidCallback set to %v, want
about 500 minutes", bf.lastValidCallback)
+ }
+ if got, want := len(bf.callbacks), 3; got != want {
+ t.Fatalf("RegisterCallback() called twice, got %v callbacks,
want %v", got, want)
Review comment:
I like it, good call
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]