mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-21 16:42:59 +00:00
``` $ gvt delete github.com/weaveworks/common $ gvt fetch --revision 4d96fd8dcf2c7b417912c6219b310112cb4a4626 github.com/weaveworks/common 2018/07/23 15:31:11 Fetching: github.com/weaveworks/common 2018/07/23 15:31:14 · Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:14 · Fetching recursive dependency: github.com/pkg/errors 2018/07/23 15:31:16 · Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:31:16 · Fetching recursive dependency: github.com/sirupsen/logrus 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/sys/unix 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/crypto/ssh/terminal 2018/07/23 15:31:18 · Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:18 · Skipping (existing): github.com/gorilla/mux 2018/07/23 15:31:18 · Fetching recursive dependency: github.com/opentracing-contrib/go-stdlib/nethttp 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:20 · Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:31:20 · Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:20 · Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:20 · Fetching recursive dependency: github.com/go-kit/kit/log 2018/07/23 15:31:23 ·· Fetching recursive dependency: github.com/go-logfmt/logfmt 2018/07/23 15:31:25 ··· Fetching recursive dependency: github.com/kr/logfmt 2018/07/23 15:31:27 ·· Fetching recursive dependency: github.com/go-stack/stack 2018/07/23 15:31:29 · Fetching recursive dependency: google.golang.org/genproto/googleapis/rpc/status 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:37 · Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:37 · Fetching recursive dependency: github.com/sercand/kuberesolver 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/resolver 2018/07/23 15:31:39 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:39 · Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:39 · Skipping (existing): github.com/armon/go-socks5 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:39 · Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/ptypes 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:39 · Fetching recursive dependency: github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:41 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:31:41 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:41 · Fetching recursive dependency: github.com/uber/jaeger-client-go/config 2018/07/23 15:31:44 ·· Fetching recursive dependency: github.com/uber/jaeger-client-go/internal/throttler/remote 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go/utils 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/agent 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/jaeger 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/zipkincore 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/crossdock/crossdock-go 2018/07/23 15:31:46 ····· Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:46 ····· Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:46 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:46 ···· Fetching recursive dependency: go.uber.org/zap/zapcore 2018/07/23 15:31:49 ····· Fetching recursive dependency: go.uber.org/atomic 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/zap/internal/bufferpool 2018/07/23 15:31:51 ······ Fetching recursive dependency: go.uber.org/zap/buffer 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/multierr 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/exit 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/color 2018/07/23 15:31:54 ···· Fetching recursive dependency: go.uber.org/zap 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:54 ···· Fetching recursive dependency: github.com/uber/jaeger-lib/metrics 2018/07/23 15:31:56 ····· Fetching recursive dependency: github.com/uber-go/tally 2018/07/23 15:31:58 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus/promhttp 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:00 ······ Fetching recursive dependency: gopkg.in/validator.v2 2018/07/23 15:32:06 ······ Fetching recursive dependency: github.com/cactus/go-statsd-client/statsd 2018/07/23 15:32:08 ······ Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/procfs 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:08 ······· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:08 ······· Skipping (existing): github.com/beorn7/perks/quantile 2018/07/23 15:32:08 ······· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/model 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/apache/thrift/lib/go/thrift 2018/07/23 15:32:13 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:13 ····· Fetching recursive dependency: github.com/go-kit/kit/metrics/influx 2018/07/23 15:32:13 ······ Fetching recursive dependency: github.com/influxdata/influxdb/client/v2 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/influxdata/influxdb/models 2018/07/23 15:32:17 ········ Fetching recursive dependency: github.com/influxdata/influxdb/pkg/escape 2018/07/23 15:32:17 ······ Fetching recursive dependency: github.com/go-kit/kit/metrics 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/performancecopilot/speed 2018/07/23 15:32:19 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/aws 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/sdk 2018/07/23 15:32:28 ········ Skipping (existing): github.com/go-ini/ini 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/sts 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol/query 2018/07/23 15:32:28 ·········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/awsutil 2018/07/23 15:32:28 ·········· Skipping (existing): github.com/jmespath/go-jmespath 2018/07/23 15:32:28 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:32:29 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface 2018/07/23 15:32:29 ······· Fetching recursive dependency: golang.org/x/sync/errgroup 2018/07/23 15:32:31 ········ Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/go-kit/kit/util/conn 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/VividCortex/gohistogram 2018/07/23 15:32:33 ····· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:33 ····· Fetching recursive dependency: github.com/codahale/hdrhistogram 2018/07/23 15:32:35 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:35 · Fetching recursive dependency: github.com/mwitkow/go-grpc-middleware 2018/07/23 15:32:37 ·· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware/logging 2018/07/23 15:32:39 ··· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware 2018/07/23 15:32:39 ···· Fetching recursive dependency: github.com/golang/protobuf/jsonpb 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/timestamp 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/duration 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/struct 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/wrappers 2018/07/23 15:32:42 ···· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:42 ···· Fetching recursive dependency: github.com/stretchr/testify/suite 2018/07/23 15:32:45 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ····· Fetching recursive dependency: github.com/stretchr/testify/require 2018/07/23 15:32:45 ······ Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ···· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:45 ···· Fetching recursive dependency: github.com/gogo/protobuf/gogoproto 2018/07/23 15:32:48 ····· Fetching recursive dependency: github.com/gogo/protobuf/protoc-gen-gogo/descriptor 2018/07/23 15:32:48 ······ Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ····· Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ···· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ··· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ··· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 · Fetching recursive dependency: github.com/weaveworks/promrus 2018/07/23 15:32:53 ·· Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:53 ·· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:32:53 ·· Fetching recursive dependency: github.com/stretchr/objx 2018/07/23 15:32:55 ·· Fetching recursive dependency: gopkg.in/alecthomas/kingpin.v2 2018/07/23 15:32:58 ··· Fetching recursive dependency: github.com/alecthomas/units 2018/07/23 15:33:00 ··· Fetching recursive dependency: github.com/alecthomas/template 2018/07/23 15:33:02 ·· Fetching recursive dependency: github.com/julienschmidt/httprouter 2018/07/23 15:33:05 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): github.com/aws/aws-sdk-go/aws/credentials 2018/07/23 15:33:05 · Skipping (existing): github.com/golang/protobuf/ptypes/empty 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/tools/cover 2018/07/23 15:33:05 · Skipping (existing): github.com/mgutz/ansi ```
641 lines
21 KiB
Go
641 lines
21 KiB
Go
// Copyright (c) 2016 Uber Technologies, Inc.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
package crossdock
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/crossdock/crossdock-go/assert"
|
|
"github.com/crossdock/crossdock-go/require"
|
|
)
|
|
|
|
// Assert builds an Assertions object that logs success or failure for all
|
|
// operations to the given T. The behavior will continue executing in case of
|
|
// failure.
|
|
//
|
|
// The following will log exactly len(tests) entries.
|
|
//
|
|
// assert := Assert(t)
|
|
// for _, tt := range tests {
|
|
// assert.Equals(tt.want, f(tt.give), "expected f(%v) == %v", tt.give, tt.want)
|
|
// }
|
|
func Assert(t T) Assertions {
|
|
return sinkAssertions{t, assert.New(sinkTestingT{t})}
|
|
}
|
|
|
|
// Checks builds an Assertions object that logs only failures to the given T.
|
|
// The behavior will continue executing in case of failure.
|
|
//
|
|
// The following will log only as many entries as invalid test cases.
|
|
//
|
|
// checks := Checks(t)
|
|
// for _, tt := range tests {
|
|
// checks.Equals(tt.want, f(tt.give), "expected f(%v) == %v", tt.give, tt.want)
|
|
// }
|
|
func Checks(t T) Assertions {
|
|
return assert.New(sinkTestingT{t})
|
|
}
|
|
|
|
// Require builds an Assertions object that logs success or failure for all
|
|
// operations to the given T. Execution of the behavior will be terminated
|
|
// immediately on the first failing assertion.
|
|
//
|
|
// The following will log one entry for each successful test case starting at
|
|
// the first one and the first failure that is encountered.
|
|
//
|
|
// require := Require(t)
|
|
// for _, tt := range tests {
|
|
// require.Equals(tt.want, f(tt.give), "expected f(%v) == %v", tt.give, tt.want)
|
|
// }
|
|
func Require(t T) Assertions {
|
|
return sinkAssertions{t, requireAssertions{require.New(sinkTestingT{t})}}
|
|
}
|
|
|
|
// Fatals builds an Assertions object that logs only failures to the given
|
|
// T. Execution of the behavior will be terminated immediately on the first
|
|
// failing assertion.
|
|
//
|
|
// The following will log the first failure encountered or nothing if all test
|
|
// cases were succesful.
|
|
//
|
|
// fatals := Fatals(t)
|
|
// for _, tt := range tests {
|
|
// fatals.Equals(tt.want, f(tt.give), "expected f(%v) == %v", tt.give, tt.want)
|
|
// }
|
|
func Fatals(t T) Assertions {
|
|
return requireAssertions{require.New(sinkTestingT{t})}
|
|
}
|
|
|
|
// sinkTestingT adapts a crossdock.T into an {require,assert}.TestingT
|
|
type sinkTestingT struct{ t T }
|
|
|
|
func (st sinkTestingT) FailNow() { st.t.FailNow() }
|
|
|
|
func (st sinkTestingT) Errorf(format string, args ...interface{}) {
|
|
// We need to prepend a newline because the error message from testify
|
|
// always includes a \r at the start.
|
|
st.t.Errorf("\n"+format, args...)
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Assertions
|
|
|
|
// Assertions provides helpers to assert conditions in crossdock behaviors.
|
|
//
|
|
// All assertions can include informative error messages formatted using
|
|
// fmt.Sprintf style,
|
|
//
|
|
// assert := Assert(t)
|
|
// assert.Contains(foo, "bar", "expected to find 'bar' in %q", foo)
|
|
//
|
|
// All assert operations return true if the condition was met and false
|
|
// otherwise. This allows gating operations that would otherwise panic behind
|
|
// preconditions.
|
|
//
|
|
// if assert.Error(t, err, "expected failure") {
|
|
// assert.Contains(t, err.Error(), "something went wrong", "error message mismatch")
|
|
// }
|
|
//
|
|
// Additionally, in case of failure, all Assertions make an attempt to
|
|
// provide a stack trace in the error message.
|
|
//
|
|
// Four kinds of Assertions objects are offered via the corresponding
|
|
// functions:
|
|
//
|
|
// Assert(T): All asserts will result in a success or failure being logged to the
|
|
// crossdock.T. Execution will continue on failure.
|
|
//
|
|
// Checks(T): Only failures will be logged to crossdock.T. Execution will
|
|
// continue on failure.
|
|
//
|
|
// Require(T): All asserts will result in a success or failure being logged to
|
|
// the crossdock.T. Execution of the behavior will be terminated immediately
|
|
// on failure.
|
|
//
|
|
// Fatals(t): Only failures will be logged to crossdock.T. Execution of the
|
|
// behavior will be temrinated immediately on failure.
|
|
//
|
|
// +--------+--------+---------+--------+
|
|
// | Assert | Checks | Require | Fatals |
|
|
// +--------------------+--------+--------+---------+--------+
|
|
// | Log on success | Yes | No | Yes | No |
|
|
// +--------------------+--------+--------+---------+--------+
|
|
// | Continue execution | Yes | Yes | No | No |
|
|
// | on failure | | | | |
|
|
// +--------------------+--------+--------+---------+--------+
|
|
//
|
|
type Assertions interface {
|
|
Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool
|
|
Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
|
|
Empty(object interface{}, msgAndArgs ...interface{}) bool
|
|
Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
|
|
EqualError(theError error, errString string, msgAndArgs ...interface{}) bool
|
|
EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
|
|
Error(err error, msgAndArgs ...interface{}) bool
|
|
Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
|
|
Fail(failureMessage string, msgAndArgs ...interface{}) bool
|
|
FailNow(failureMessage string, msgAndArgs ...interface{}) bool
|
|
False(value bool, msgAndArgs ...interface{}) bool
|
|
Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
|
|
InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
|
|
InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
|
|
InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool
|
|
InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
|
|
IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
|
|
JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool
|
|
Len(object interface{}, length int, msgAndArgs ...interface{}) bool
|
|
Nil(object interface{}, msgAndArgs ...interface{}) bool
|
|
NoError(err error, msgAndArgs ...interface{}) bool
|
|
NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool
|
|
NotEmpty(object interface{}, msgAndArgs ...interface{}) bool
|
|
NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool
|
|
NotNil(object interface{}, msgAndArgs ...interface{}) bool
|
|
NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
|
|
NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
|
|
NotZero(i interface{}, msgAndArgs ...interface{}) bool
|
|
Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
|
|
Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
|
|
True(value bool, msgAndArgs ...interface{}) bool
|
|
WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool
|
|
Zero(i interface{}, msgAndArgs ...interface{}) bool
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// T => TestingT
|
|
|
|
func formatMsgAndArgs(msgAndArgs []interface{}) string {
|
|
if len(msgAndArgs) == 0 {
|
|
return ""
|
|
}
|
|
if len(msgAndArgs) == 1 {
|
|
return msgAndArgs[0].(string)
|
|
}
|
|
return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
|
|
}
|
|
|
|
type sinkAssertions struct {
|
|
// We need to wrap assert rather than using it as-is because we need to
|
|
// log success messages.
|
|
t T
|
|
a Assertions
|
|
}
|
|
|
|
var _ Assertions = (*sinkAssertions)(nil)
|
|
|
|
func (sa sinkAssertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Condition(comp, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Contains(s, contains, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Empty(object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Equal(expected, actual, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
|
|
if sa.a.EqualError(theError, errString, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.EqualValues(expected, actual, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Error(err error, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Error(err, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Exactly(expected, actual, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Fail(failureMessage, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
|
|
if sa.a.FailNow(failureMessage, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) False(value bool, msgAndArgs ...interface{}) bool {
|
|
if sa.a.False(value, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Implements(interfaceObject, object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
if sa.a.InDelta(expected, actual, delta, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
if sa.a.InDeltaSlice(expected, actual, delta, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
|
|
if sa.a.InEpsilon(expected, actual, epsilon, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
if sa.a.InEpsilonSlice(expected, actual, delta, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.IsType(expectedType, object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
|
|
if sa.a.JSONEq(expected, actual, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Len(object, length, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Nil(object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NoError(err error, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NoError(err, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotContains(s, contains, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotEmpty(object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotEqual(expected, actual, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotNil(object, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotPanics(f, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotRegexp(rx, str, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.NotZero(i, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Panics(f, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Regexp(rx, str, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) True(value bool, msgAndArgs ...interface{}) bool {
|
|
if sa.a.True(value, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
|
if sa.a.WithinDuration(expected, actual, delta, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (sa sinkAssertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
|
|
if sa.a.Zero(i, msgAndArgs...) {
|
|
sa.t.Successf(formatMsgAndArgs(msgAndArgs))
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Require
|
|
|
|
// Adapts a require.Assertions into an Assertions. This simply returns true
|
|
// for all cases because execution just stops in case of failure.
|
|
type requireAssertions struct{ r *require.Assertions }
|
|
|
|
var _ Assertions = (*requireAssertions)(nil)
|
|
|
|
func (r requireAssertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool {
|
|
r.r.Condition(comp, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Contains(s, contains, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Empty(object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Equal(expected, actual, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
|
|
r.r.EqualError(theError, errString, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.EqualValues(expected, actual, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Error(err error, msgAndArgs ...interface{}) bool {
|
|
r.r.Error(err, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Exactly(expected, actual, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
|
|
r.r.Fail(failureMessage, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
|
|
r.r.FailNow(failureMessage, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) False(value bool, msgAndArgs ...interface{}) bool {
|
|
r.r.False(value, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Implements(interfaceObject, object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
r.r.InDelta(expected, actual, delta, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
r.r.InDeltaSlice(expected, actual, delta, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
|
|
r.r.InEpsilon(expected, actual, epsilon, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
|
r.r.InEpsilonSlice(expected, actual, delta, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.IsType(expectedType, object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
|
|
r.r.JSONEq(expected, actual, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
|
|
r.r.Len(object, length, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Nil(object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NoError(err error, msgAndArgs ...interface{}) bool {
|
|
r.r.NoError(err, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotContains(s, contains, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotEmpty(object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotEqual(expected, actual, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotNil(object, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool {
|
|
r.r.NotPanics(f, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotRegexp(rx, str, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.NotZero(i, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool {
|
|
r.r.Panics(f, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Regexp(rx, str, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) True(value bool, msgAndArgs ...interface{}) bool {
|
|
r.r.True(value, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
|
r.r.WithinDuration(expected, actual, delta, msgAndArgs...)
|
|
return true
|
|
}
|
|
|
|
func (r requireAssertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
|
|
r.r.Zero(i, msgAndArgs...)
|
|
return true
|
|
}
|