Depenancy upgrades and movign to dep. (#8630)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
bf24f51c4e
Коммит
6e2cb00008
77
vendor/github.com/segmentio/backo-go/backo_test.go
сгенерированный
поставляемый
77
vendor/github.com/segmentio/backo-go/backo_test.go
сгенерированный
поставляемый
@@ -1,77 +0,0 @@
|
||||
package backo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bmizerany/assert"
|
||||
)
|
||||
|
||||
// Tests default backo behaviour.
|
||||
func TestDefaults(t *testing.T) {
|
||||
backo := DefaultBacko()
|
||||
|
||||
assert.Equal(t, milliseconds(100), backo.Duration(0))
|
||||
assert.Equal(t, milliseconds(200), backo.Duration(1))
|
||||
assert.Equal(t, milliseconds(400), backo.Duration(2))
|
||||
assert.Equal(t, milliseconds(800), backo.Duration(3))
|
||||
}
|
||||
|
||||
// Tests backo does not exceed cap.
|
||||
func TestCap(t *testing.T) {
|
||||
backo := NewBacko(milliseconds(100), 2, 0, milliseconds(600))
|
||||
|
||||
assert.Equal(t, milliseconds(100), backo.Duration(0))
|
||||
assert.Equal(t, milliseconds(200), backo.Duration(1))
|
||||
assert.Equal(t, milliseconds(400), backo.Duration(2))
|
||||
assert.Equal(t, milliseconds(600), backo.Duration(3))
|
||||
}
|
||||
|
||||
// Tests that jitter adds randomness.
|
||||
func TestJitter(t *testing.T) {
|
||||
defaultBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
|
||||
jitterBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
|
||||
|
||||
// TODO: Check jittered durations are within a range.
|
||||
assert.NotEqual(t, jitterBacko.Duration(0), defaultBacko.Duration(0))
|
||||
assert.NotEqual(t, jitterBacko.Duration(1), defaultBacko.Duration(1))
|
||||
assert.NotEqual(t, jitterBacko.Duration(2), defaultBacko.Duration(2))
|
||||
assert.NotEqual(t, jitterBacko.Duration(3), defaultBacko.Duration(3))
|
||||
}
|
||||
|
||||
func ExampleBacko_BackoffDefault() {
|
||||
b := DefaultBacko()
|
||||
ticker := b.NewTicker()
|
||||
|
||||
for i := 0; i < 6; i++ {
|
||||
start := time.Now()
|
||||
select {
|
||||
case t := <-ticker.C:
|
||||
fmt.Println(nearest10Millis(t.Sub(start)))
|
||||
}
|
||||
}
|
||||
|
||||
ticker.Stop()
|
||||
|
||||
// Output:
|
||||
// 100
|
||||
// 200
|
||||
// 400
|
||||
// 800
|
||||
// 1600
|
||||
// 3200
|
||||
}
|
||||
|
||||
func nearest10Millis(d time.Duration) float64 {
|
||||
// Typically d is something like 11 or 21, so do some magic to round the
|
||||
// durations to the nearest 10. We divide d by 10, floor it, and multiply it
|
||||
// by 10 again.
|
||||
return math.Floor(float64(d/time.Millisecond/10) * 10)
|
||||
}
|
||||
|
||||
// Returns the given milliseconds as time.Duration
|
||||
func milliseconds(ms int64) time.Duration {
|
||||
return time.Duration(ms * 1000 * 1000)
|
||||
}
|
||||
7
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore
сгенерированный
поставляемый
7
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore
сгенерированный
поставляемый
@@ -1,7 +0,0 @@
|
||||
_go_.*
|
||||
_gotest_.*
|
||||
_obj
|
||||
_test
|
||||
_testmain.go
|
||||
*.out
|
||||
*.[568]
|
||||
45
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md
сгенерированный
поставляемый
45
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md
сгенерированный
поставляемый
@@ -1,45 +0,0 @@
|
||||
# Assert (c) Blake Mizerany and Keith Rarick -- MIT LICENCE
|
||||
|
||||
## Assertions for Go tests
|
||||
|
||||
## Install
|
||||
|
||||
$ go get github.com/bmizerany/assert
|
||||
|
||||
## Use
|
||||
|
||||
**point.go**
|
||||
|
||||
package point
|
||||
|
||||
type Point struct {
|
||||
x, y int
|
||||
}
|
||||
|
||||
**point_test.go**
|
||||
|
||||
|
||||
package point
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/bmizerany/assert"
|
||||
)
|
||||
|
||||
func TestAsserts(t *testing.T) {
|
||||
p1 := Point{1, 1}
|
||||
p2 := Point{2, 1}
|
||||
|
||||
assert.Equal(t, p1, p2)
|
||||
}
|
||||
|
||||
**output**
|
||||
$ go test
|
||||
--- FAIL: TestAsserts (0.00 seconds)
|
||||
assert.go:15: /Users/flavio.barbosa/dev/stewie/src/point_test.go:12
|
||||
assert.go:24: ! X: 1 != 2
|
||||
FAIL
|
||||
|
||||
## Docs
|
||||
|
||||
http://github.com/bmizerany/assert
|
||||
76
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go
сгенерированный
поставляемый
76
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go
сгенерированный
поставляемый
@@ -1,76 +0,0 @@
|
||||
package assert
|
||||
// Testing helpers for doozer.
|
||||
|
||||
import (
|
||||
"github.com/kr/pretty"
|
||||
"reflect"
|
||||
"testing"
|
||||
"runtime"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func assert(t *testing.T, result bool, f func(), cd int) {
|
||||
if !result {
|
||||
_, file, line, _ := runtime.Caller(cd + 1)
|
||||
t.Errorf("%s:%d", file, line)
|
||||
f()
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func equal(t *testing.T, exp, got interface{}, cd int, args ...interface{}) {
|
||||
fn := func() {
|
||||
for _, desc := range pretty.Diff(exp, got) {
|
||||
t.Error("!", desc)
|
||||
}
|
||||
if len(args) > 0 {
|
||||
t.Error("!", " -", fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
result := reflect.DeepEqual(exp, got)
|
||||
assert(t, result, fn, cd+1)
|
||||
}
|
||||
|
||||
func tt(t *testing.T, result bool, cd int, args ...interface{}) {
|
||||
fn := func() {
|
||||
t.Errorf("! Failure")
|
||||
if len(args) > 0 {
|
||||
t.Error("!", " -", fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
assert(t, result, fn, cd+1)
|
||||
}
|
||||
|
||||
func T(t *testing.T, result bool, args ...interface{}) {
|
||||
tt(t, result, 1, args...)
|
||||
}
|
||||
|
||||
func Tf(t *testing.T, result bool, format string, args ...interface{}) {
|
||||
tt(t, result, 1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func Equal(t *testing.T, exp, got interface{}, args ...interface{}) {
|
||||
equal(t, exp, got, 1, args...)
|
||||
}
|
||||
|
||||
func Equalf(t *testing.T, exp, got interface{}, format string, args ...interface{}) {
|
||||
equal(t, exp, got, 1, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func NotEqual(t *testing.T, exp, got interface{}, args ...interface{}) {
|
||||
fn := func() {
|
||||
t.Errorf("! Unexpected: <%#v>", exp)
|
||||
if len(args) > 0 {
|
||||
t.Error("!", " -", fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
result := !reflect.DeepEqual(exp, got)
|
||||
assert(t, result, fn, 1)
|
||||
}
|
||||
|
||||
func Panic(t *testing.T, err interface{}, fn func()) {
|
||||
defer func() {
|
||||
equal(t, err, recover(), 3)
|
||||
}()
|
||||
fn()
|
||||
}
|
||||
15
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go
сгенерированный
поставляемый
15
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go
сгенерированный
поставляемый
@@ -1,15 +0,0 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLineNumbers(t *testing.T) {
|
||||
Equal(t, "foo", "foo", "msg!")
|
||||
//Equal(t, "foo", "bar", "this should blow up")
|
||||
}
|
||||
|
||||
func TestNotEqual(t *testing.T) {
|
||||
NotEqual(t, "foo", "bar", "msg!")
|
||||
//NotEqual(t, "foo", "foo", "this should blow up")
|
||||
}
|
||||
5
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go
сгенерированный
поставляемый
5
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
package point
|
||||
|
||||
type Point struct {
|
||||
X, Y int
|
||||
}
|
||||
13
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go
сгенерированный
поставляемый
13
vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go
сгенерированный
поставляемый
@@ -1,13 +0,0 @@
|
||||
package point
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"assert"
|
||||
)
|
||||
|
||||
func TestAsserts(t *testing.T) {
|
||||
p1 := Point{1, 1}
|
||||
p2 := Point{2, 1}
|
||||
|
||||
assert.Equal(t, p1, p2)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user