Package list golang-github-go-kit-kit / lintian-fixes/main circuitbreaker / handy_breaker_test.go
lintian-fixes/main

Tree @lintian-fixes/main (Download .tar.gz)

handy_breaker_test.go @lintian-fixes/main

569b930
 
 
 
 
8317f15
569b930
 
 
 
 
 
8317f15
4a67d58
8317f15
 
 
569b930
e8ced30
569b930
package circuitbreaker_test

import (
	"testing"

	handybreaker "github.com/streadway/handy/breaker"

	"github.com/go-kit/kit/circuitbreaker"
)

func TestHandyBreaker(t *testing.T) {
	var (
		failureRatio     = 0.05
		breaker          = circuitbreaker.HandyBreaker(handybreaker.NewBreaker(failureRatio))
		primeWith        = handybreaker.DefaultMinObservations * 10
		shouldPass       = func(n int) bool { return (float64(n) / float64(primeWith+n)) <= failureRatio }
		openCircuitError = handybreaker.ErrCircuitOpen.Error()
	)
	testFailingEndpoint(t, breaker, primeWith, shouldPass, 0, openCircuitError)
}