forked from toolshed/abra
cli
cmd
pkg
app
autocomplete
catalogue
client
client.go
context.go
registry.go
secret.go
volumes.go
volumes_test.go
config
container
context
dns
envfile
formatter
git
integration
limit
lint
log
recipe
secret
server
service
ssh
test
upstream
web
scripts
tests
vendor
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
27 lines
461 B
Go
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)
|
|
}
|
|
}
|