abra/pkg/client/volumes_test.go
p4u1 d5ac3958a4
All checks were successful
continuous-integration/drone/push Build is passing
feat: add retries to app volume remove
2024-03-27 05:38:24 +00:00

27 lines
461 B
Go

package client
import (
"fmt"
"testing"
)
func TestRetryFunc(t *testing.T) {
err := retryFunc(1, func() error { return nil })
if err != nil {
t.Errorf("should not return an error: %s", err)
}
i := 0
fn := func() error {
i++
return fmt.Errorf("oh no, something went wrong!")
}
err = retryFunc(2, fn)
if err == nil {
t.Error("should return an error")
}
if i != 2 {
t.Errorf("The function should have been called 1 times, got %d", i)
}
}