mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
opentracing -> opencensus (#802)
* update vendor directory, add go.opencensus.io * update imports * oops * s/opentracing/opencensus/ & remove prometheus / zipkin stuff & remove old stats * the dep train rides again * fix gin build * deps from last guy * start in on the agent metrics * she builds * remove tags for now, cardinality error is fussing. subscribe instead of register * update to patched version of opencensus to proceed for now TODO switch to a release * meh fix imports * println debug the bad boys * lace it with the tags * update deps again * fix all inconsistent cardinality errors * add our own logger * fix init * fix oom measure * remove bugged removal code * fix s3 measures * fix prom handler nil
This commit is contained in:
63
vendor/github.com/go-openapi/strfmt/duration_test.go
generated
vendored
63
vendor/github.com/go-openapi/strfmt/duration_test.go
generated
vendored
@@ -38,6 +38,12 @@ func TestDuration(t *testing.T) {
|
||||
err = pp.UnmarshalText(b)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = pp.UnmarshalText([]byte("three week"))
|
||||
assert.Error(t, err)
|
||||
|
||||
err = pp.UnmarshalText([]byte("9999999999999999999999999999999999999999999999999999999 weeks"))
|
||||
assert.Error(t, err)
|
||||
|
||||
txt, err := pp.MarshalText()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, orig, string(txt))
|
||||
@@ -46,6 +52,15 @@ func TestDuration(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, orig, pp.String())
|
||||
|
||||
err = pp.UnmarshalJSON([]byte("yada"))
|
||||
assert.Error(t, err)
|
||||
|
||||
err = pp.UnmarshalJSON([]byte(`"12 parsecs"`))
|
||||
assert.Error(t, err)
|
||||
|
||||
err = pp.UnmarshalJSON([]byte(`"12 y"`))
|
||||
assert.Error(t, err)
|
||||
|
||||
b, err = pp.MarshalJSON()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bj, b)
|
||||
@@ -66,6 +81,16 @@ func testDurationParser(t *testing.T, toParse string, expected time.Duration) {
|
||||
assert.Equal(t, expected, r)
|
||||
}
|
||||
|
||||
func TestDurationParser_Failed(t *testing.T) {
|
||||
_, e := ParseDuration("45 wekk")
|
||||
assert.Error(t, e)
|
||||
}
|
||||
|
||||
func TestIsDuration_Failed(t *testing.T) {
|
||||
e := IsDuration("45 weeekks")
|
||||
assert.False(t, e)
|
||||
}
|
||||
|
||||
func testDurationSQLScanner(t *testing.T, dur time.Duration) {
|
||||
values := []interface{}{int64(dur), float64(dur)}
|
||||
for _, value := range values {
|
||||
@@ -73,9 +98,25 @@ func testDurationSQLScanner(t *testing.T, dur time.Duration) {
|
||||
err := result.Scan(value)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, dur, time.Duration(result))
|
||||
|
||||
// And the other way arround
|
||||
resv, erv := result.Value()
|
||||
assert.NoError(t, erv)
|
||||
assert.EqualValues(t, value, resv)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestDurationScanner_Nil(t *testing.T) {
|
||||
var result Duration
|
||||
err := result.Scan(nil)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, time.Duration(result))
|
||||
|
||||
err = result.Scan("1 ms")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestDurationParser(t *testing.T) {
|
||||
testcases := map[string]time.Duration{
|
||||
|
||||
@@ -141,3 +182,25 @@ func TestDurationParser(t *testing.T) {
|
||||
testDurationSQLScanner(t, dur)
|
||||
}
|
||||
}
|
||||
func TestIsDuration_Caveats(t *testing.T) {
|
||||
// This works too
|
||||
e := IsDuration("45 weeks")
|
||||
assert.True(t, e)
|
||||
|
||||
// This works too
|
||||
e = IsDuration("45 weekz")
|
||||
assert.True(t, e)
|
||||
|
||||
// This works too
|
||||
e = IsDuration("12 hours")
|
||||
assert.True(t, e)
|
||||
|
||||
// This works too
|
||||
e = IsDuration("12 minutes")
|
||||
assert.True(t, e)
|
||||
|
||||
// This does not work
|
||||
e = IsDuration("12 phours")
|
||||
assert.False(t, e)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user