From a72ef7ca0e3ccc60a91c2a5e21ec65a1f9a648c3 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 14 Aug 2019 14:58:30 +0100 Subject: [PATCH] vendor: update github.com/yunify/qingstor-sdk-go to v3 --- go.mod | 5 +- go.sum | 10 +- .../go-shared/log/context_free_logger.go | 79 ++ .../github.com/pengsrc/go-shared/log/event.go | 10 +- .../pengsrc/go-shared/log/exported.go | 12 +- .../pengsrc/go-shared/log/logger.go | 12 +- .../testify/assert/assertion_format.go | 63 ++ .../testify/assert/assertion_forward.go | 126 ++++ .../testify/assert/assertion_order.go | 309 ++++++++ .../stretchr/testify/assert/assertions.go | 38 +- .../stretchr/testify/require/require.go | 678 +++++++++++------- .../stretchr/testify/require/require.go.tmpl | 2 +- .../testify/require/require_forward.go | 126 ++++ .../yunify/qingstor-sdk-go/.travis.yml | 55 -- .../yunify/qingstor-sdk-go/MAINTAINERS | 1 - .../yunify/qingstor-sdk-go/glide.lock | 32 - .../yunify/qingstor-sdk-go/glide.yaml | 11 - .../request/builder/qingstor.go | 163 ----- .../qingstor-sdk-go/{ => v3}/.gitignore | 0 .../qingstor-sdk-go/{ => v3}/.gitmodules | 0 .../yunify/qingstor-sdk-go/v3/.travis.yml | 39 + .../yunify/qingstor-sdk-go/{ => v3}/AUTHORS | 0 .../qingstor-sdk-go/{ => v3}/CHANGELOG.md | 38 + .../yunify/qingstor-sdk-go/{ => v3}/LICENSE | 0 .../yunify/qingstor-sdk-go/v3/MAINTAINERS | 1 + .../yunify/qingstor-sdk-go/{ => v3}/Makefile | 23 +- .../yunify/qingstor-sdk-go/{ => v3}/README.md | 4 +- .../qingstor-sdk-go/{ => v3}/config/config.go | 4 +- .../{ => v3}/config/contract.go | 0 .../yunify/qingstor-sdk-go/v3/go.mod | 9 + .../yunify/qingstor-sdk-go/v3/go.sum | 13 + .../qingstor-sdk-go/{ => v3}/logger/logger.go | 0 .../base.go => v3/request/builder/builder.go} | 290 +++++--- .../{ => v3}/request/data/input.go | 0 .../{ => v3}/request/data/operation.go | 2 +- .../{ => v3}/request/data/validation.go | 0 .../{ => v3}/request/errors/parameters.go | 0 .../{ => v3}/request/errors/qingstor.go | 0 .../{ => v3}/request/request.go | 12 +- .../{ => v3}/request/signer/qingstor.go | 4 +- .../{ => v3}/request/unpacker/base.go | 4 +- .../{ => v3}/request/unpacker/qingstor.go | 64 +- .../{ => v3}/service/bucket.go | 10 +- .../{ => v3}/service/convert_types.go | 0 .../{ => v3}/service/object.go | 12 +- .../{ => v3}/service/qingstor.go | 6 +- .../qingstor-sdk-go/{ => v3}/service/types.go | 4 +- .../qingstor-sdk-go/{ => v3}/utils/conn.go | 9 +- .../qingstor-sdk-go/{ => v3}/utils/escape.go | 0 .../qingstor-sdk-go/{ => v3}/version.go | 2 +- vendor/modules.txt | 28 +- 51 files changed, 1560 insertions(+), 750 deletions(-) create mode 100644 vendor/github.com/pengsrc/go-shared/log/context_free_logger.go create mode 100644 vendor/github.com/stretchr/testify/assert/assertion_order.go delete mode 100644 vendor/github.com/yunify/qingstor-sdk-go/.travis.yml delete mode 100644 vendor/github.com/yunify/qingstor-sdk-go/MAINTAINERS delete mode 100644 vendor/github.com/yunify/qingstor-sdk-go/glide.lock delete mode 100644 vendor/github.com/yunify/qingstor-sdk-go/glide.yaml delete mode 100644 vendor/github.com/yunify/qingstor-sdk-go/request/builder/qingstor.go rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/.gitignore (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/.gitmodules (100%) create mode 100644 vendor/github.com/yunify/qingstor-sdk-go/v3/.travis.yml rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/AUTHORS (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/CHANGELOG.md (80%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/LICENSE (100%) create mode 100644 vendor/github.com/yunify/qingstor-sdk-go/v3/MAINTAINERS rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/Makefile (77%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/README.md (96%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/config/config.go (98%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/config/contract.go (100%) create mode 100644 vendor/github.com/yunify/qingstor-sdk-go/v3/go.mod create mode 100644 vendor/github.com/yunify/qingstor-sdk-go/v3/go.sum rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/logger/logger.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{request/builder/base.go => v3/request/builder/builder.go} (54%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/data/input.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/data/operation.go (96%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/data/validation.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/errors/parameters.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/errors/qingstor.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/request.go (94%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/signer/qingstor.go (98%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/unpacker/base.go (98%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/request/unpacker/qingstor.go (56%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/service/bucket.go (99%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/service/convert_types.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/service/object.go (98%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/service/qingstor.go (95%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/service/types.go (99%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/utils/conn.go (96%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/utils/escape.go (100%) rename vendor/github.com/yunify/qingstor-sdk-go/{ => v3}/version.go (97%) diff --git a/go.mod b/go.mod index 53987fedd..31d243ad5 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,6 @@ require ( github.com/onsi/ginkgo v1.8.0 // indirect github.com/onsi/gomega v1.5.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pengsrc/go-shared v0.2.0 // indirect github.com/pkg/errors v0.8.1 github.com/pkg/sftp v1.10.1-0.20190523025818-e98a7bef6829 github.com/rfjakob/eme v0.0.0-20171028163933-2222dbd4ba46 @@ -47,10 +46,10 @@ require ( github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.3 - github.com/stretchr/testify v1.3.0 + github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 github.com/t3rm1n4l/go-mega v0.0.0-20190528125457-55e675378686 github.com/xanzy/ssh-agent v0.2.1 - github.com/yunify/qingstor-sdk-go v2.2.15+incompatible + github.com/yunify/qingstor-sdk-go/v3 v3.0.2 go.etcd.io/bbolt v1.3.3 // indirect go.opencensus.io v0.22.0 // indirect golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 diff --git a/go.sum b/go.sum index da3c0dbc7..fa4dbc8ac 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pengsrc/go-shared v0.2.0 h1:Ho86LhaXOYgv9FjBmIp5CO0LmaIj49H2HZhYh0+7uW8= -github.com/pengsrc/go-shared v0.2.0/go.mod h1:jVblp62SafmidSkvWrXyxAme3gaTfEtWwRPGz5cpvHg= +github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14 h1:XeOYlK9W1uCmhjJSsY78Mcuh7MVkNjTzmHx1yBzizSU= +github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14/go.mod h1:jVblp62SafmidSkvWrXyxAme3gaTfEtWwRPGz5cpvHg= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -182,6 +182,8 @@ github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 h1:Ko2LQMrRU+Oy/+EDBwX7eZ2jp3C47eDBB8EIhKTun+I= +github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/t3rm1n4l/go-mega v0.0.0-20190528125457-55e675378686 h1:U7mF+tjDK9zWoxCU+kBNa1XT7WZMF5bjwtRpjeIkSYw= github.com/t3rm1n4l/go-mega v0.0.0-20190528125457-55e675378686/go.mod h1:XWL4vDyd3JKmJx+hZWUVgCNmmhZ2dTBcaNDcxH465s0= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= @@ -190,8 +192,8 @@ github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPyS github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yunify/qingstor-sdk-go v2.2.15+incompatible h1:/Z0q3/eSMoPYAuRmhjWtuGSmVVciFC6hfm3yfCKuvz0= -github.com/yunify/qingstor-sdk-go v2.2.15+incompatible/go.mod h1:w6wqLDQ5bBTzxGJ55581UrSwLrsTAsdo9N6yX/8d9RY= +github.com/yunify/qingstor-sdk-go/v3 v3.0.2 h1:2pL3tEj6eEESsHKrqsLZ5D+OkHEhYfsW1xwYRcHCgZs= +github.com/yunify/qingstor-sdk-go/v3 v3.0.2/go.mod h1:KciFNuMu6F4WLk9nGwwK69sCGKLCdd9f97ac/wfumS4= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/vendor/github.com/pengsrc/go-shared/log/context_free_logger.go b/vendor/github.com/pengsrc/go-shared/log/context_free_logger.go new file mode 100644 index 000000000..99984f639 --- /dev/null +++ b/vendor/github.com/pengsrc/go-shared/log/context_free_logger.go @@ -0,0 +1,79 @@ +package log + +import ( + "context" +) + +// ContextFreeLogger is a logger that doesn't take context. +type ContextFreeLogger struct { + Logger *Logger + + ctx context.Context +} + +// Fatal logs a message with severity FATAL followed by a call to os.Exit(1). +func (l *ContextFreeLogger) Fatal(v ...interface{}) { + l.Logger.event(l.ctx, FatalLevel).write("%v", v...) +} + +// Panic logs a message with severity PANIC followed by a call to panic(). +func (l *ContextFreeLogger) Panic(v ...interface{}) { + l.Logger.event(l.ctx, PanicLevel).write("%v", v...) +} + +// Error logs a message with severity ERROR. +func (l *ContextFreeLogger) Error(v ...interface{}) { + l.Logger.event(l.ctx, ErrorLevel).write("%v", v...) +} + +// Warn logs a message with severity WARN. +func (l *ContextFreeLogger) Warn(v ...interface{}) { + l.Logger.event(l.ctx, WarnLevel).write("%v", v...) +} + +// Info logs a message with severity INFO. +func (l *ContextFreeLogger) Info(v ...interface{}) { + l.Logger.event(l.ctx, InfoLevel).write("%v", v...) +} + +// Debug logs a message with severity DEBUG. +func (l *ContextFreeLogger) Debug(v ...interface{}) { + l.Logger.event(l.ctx, DebugLevel).write("%v", v...) +} + +// Fatalf logs a message with severity FATAL in format followed by a call to +// os.Exit(1). +func (l *ContextFreeLogger) Fatalf(format string, v ...interface{}) { + l.Logger.event(l.ctx, FatalLevel).write(format, v...) +} + +// Panicf logs a message with severity PANIC in format followed by a call to +// panic(). +func (l *ContextFreeLogger) Panicf(format string, v ...interface{}) { + l.Logger.event(l.ctx, PanicLevel).write(format, v...) +} + +// Errorf logs a message with severity ERROR in format. +func (l *ContextFreeLogger) Errorf(format string, v ...interface{}) { + l.Logger.event(l.ctx, ErrorLevel).write(format, v...) +} + +// Warnf logs a message with severity WARN in format. +func (l *ContextFreeLogger) Warnf(format string, v ...interface{}) { + l.Logger.event(l.ctx, WarnLevel).write(format, v...) +} + +// Infof logs a message with severity INFO in format. +func (l *ContextFreeLogger) Infof(format string, v ...interface{}) { + l.Logger.event(l.ctx, InfoLevel).write(format, v...) +} + +// Debugf logs a message with severity DEBUG in format. +func (l *ContextFreeLogger) Debugf(format string, v ...interface{}) { + l.Logger.event(l.ctx, DebugLevel).write(format, v...) +} + +// NewContextFreeLogger creates a new context free logger for given logger. +func NewContextFreeLogger(l *Logger) *ContextFreeLogger { + return &ContextFreeLogger{Logger: l, ctx: context.Background()} +} diff --git a/vendor/github.com/pengsrc/go-shared/log/event.go b/vendor/github.com/pengsrc/go-shared/log/event.go index 85f58f986..0a5575440 100644 --- a/vendor/github.com/pengsrc/go-shared/log/event.go +++ b/vendor/github.com/pengsrc/go-shared/log/event.go @@ -383,14 +383,10 @@ func (e *Event) write(format string, v ...interface{}) { defer buf.Free() // Format print message. - if format != "" { - if len(v) == 0 { - fmt.Fprint(buf, format) - } else { - fmt.Fprintf(buf, format, v...) - } + if len(v) == 0 { + fmt.Fprint(buf, format) } else { - fmt.Fprint(buf, v...) + fmt.Fprintf(buf, format, v...) } // Append filed. diff --git a/vendor/github.com/pengsrc/go-shared/log/exported.go b/vendor/github.com/pengsrc/go-shared/log/exported.go index 4259bab0f..9b2458c15 100644 --- a/vendor/github.com/pengsrc/go-shared/log/exported.go +++ b/vendor/github.com/pengsrc/go-shared/log/exported.go @@ -7,42 +7,42 @@ import ( // Fatal logs a message with severity FATAL followed by a call to os.Exit(1). func Fatal(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, FatalLevel).write("", v...) + globalLogger.event(ctx, FatalLevel).write("%v", v...) } } // Panic logs a message with severity PANIC followed by a call to panic(). func Panic(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, PanicLevel).write("", v...) + globalLogger.event(ctx, PanicLevel).write("%v", v...) } } // Error logs a message with severity ERROR. func Error(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, ErrorLevel).write("", v...) + globalLogger.event(ctx, ErrorLevel).write("%v", v...) } } // Warn logs a message with severity WARN. func Warn(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, WarnLevel).write("", v...) + globalLogger.event(ctx, WarnLevel).write("%v", v...) } } // Info logs a message with severity INFO. func Info(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, InfoLevel).write("", v...) + globalLogger.event(ctx, InfoLevel).write("%v", v...) } } // Debug logs a message with severity DEBUG. func Debug(ctx context.Context, v ...interface{}) { if globalLogger != nil { - globalLogger.event(ctx, DebugLevel).write("", v...) + globalLogger.event(ctx, DebugLevel).write("%v", v...) } } diff --git a/vendor/github.com/pengsrc/go-shared/log/logger.go b/vendor/github.com/pengsrc/go-shared/log/logger.go index f44c6a3c4..5be966198 100644 --- a/vendor/github.com/pengsrc/go-shared/log/logger.go +++ b/vendor/github.com/pengsrc/go-shared/log/logger.go @@ -74,32 +74,32 @@ func (l *Logger) Flush() { // Fatal logs a message with severity FATAL followed by a call to os.Exit(1). func (l *Logger) Fatal(ctx context.Context, v ...interface{}) { - l.event(ctx, FatalLevel).write("", v...) + l.event(ctx, FatalLevel).write("%v", v...) } // Panic logs a message with severity PANIC followed by a call to panic(). func (l *Logger) Panic(ctx context.Context, v ...interface{}) { - l.event(ctx, PanicLevel).write("", v...) + l.event(ctx, PanicLevel).write("%v", v...) } // Error logs a message with severity ERROR. func (l *Logger) Error(ctx context.Context, v ...interface{}) { - l.event(ctx, ErrorLevel).write("", v...) + l.event(ctx, ErrorLevel).write("%v", v...) } // Warn logs a message with severity WARN. func (l *Logger) Warn(ctx context.Context, v ...interface{}) { - l.event(ctx, WarnLevel).write("", v...) + l.event(ctx, WarnLevel).write("%v", v...) } // Info logs a message with severity INFO. func (l *Logger) Info(ctx context.Context, v ...interface{}) { - l.event(ctx, InfoLevel).write("", v...) + l.event(ctx, InfoLevel).write("%v", v...) } // Debug logs a message with severity DEBUG. func (l *Logger) Debug(ctx context.Context, v ...interface{}) { - l.event(ctx, DebugLevel).write("", v...) + l.event(ctx, DebugLevel).write("%v", v...) } // Fatalf logs a message with severity FATAL in format followed by a call to diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go index aa1c2b95c..8a68b608c 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -157,6 +157,31 @@ func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool return FileExists(t, path, append([]interface{}{msg}, args...)...) } +// Greaterf asserts that the first element is greater than the second +// +// assert.Greaterf(t, 2, 1, "error message %s", "formatted") +// assert.Greaterf(t, float64(2, "error message %s", "formatted"), float64(1)) +// assert.Greaterf(t, "b", "a", "error message %s", "formatted") +func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Greater(t, e1, e2, append([]interface{}{msg}, args...)...) +} + +// GreaterOrEqualf asserts that the first element in greater or equal than the second +// +// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") +func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...) +} + // HTTPBodyContainsf asserts that a specified handler returns a // body that contains a string. // @@ -300,6 +325,31 @@ func Lenf(t TestingT, object interface{}, length int, msg string, args ...interf return Len(t, object, length, append([]interface{}{msg}, args...)...) } +// Lessf asserts that the first element in less than the second +// +// assert.Lessf(t, 1, 2, "error message %s", "formatted") +// assert.Lessf(t, float64(1, "error message %s", "formatted"), float64(2)) +// assert.Lessf(t, "a", "b", "error message %s", "formatted") +func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Less(t, e1, e2, append([]interface{}{msg}, args...)...) +} + +// LessOrEqualf asserts that the first element in greater or equal than the second +// +// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") +func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...) +} + // Nilf asserts that the specified object is nil. // // assert.Nilf(t, err, "error message %s", "formatted") @@ -444,6 +494,19 @@ func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...in return Regexp(t, rx, str, append([]interface{}{msg}, args...)...) } +// Samef asserts that two pointers reference the same object. +// +// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Same(t, expected, actual, append([]interface{}{msg}, args...)...) +} + // Subsetf asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go index de39f794e..3c8012a38 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -303,6 +303,56 @@ func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) b return FileExistsf(a.t, path, msg, args...) } +// Greater asserts that the first element is greater than the second +// +// a.Greater(2, 1) +// a.Greater(float64(2), float64(1)) +// a.Greater("b", "a") +func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Greater(a.t, e1, e2, msgAndArgs...) +} + +// GreaterOrEqual asserts that the first element in greater or equal than the second +// +// a.GreaterOrEqual(2, 1) +// a.GreaterOrEqual(2, 2) +// a.GreaterOrEqual("b", "a") +// a.GreaterOrEqual("b", "b") +func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return GreaterOrEqual(a.t, e1, e2, msgAndArgs...) +} + +// GreaterOrEqualf asserts that the first element in greater or equal than the second +// +// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") +// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") +// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") +// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") +func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return GreaterOrEqualf(a.t, e1, e2, msg, args...) +} + +// Greaterf asserts that the first element is greater than the second +// +// a.Greaterf(2, 1, "error message %s", "formatted") +// a.Greaterf(float64(2, "error message %s", "formatted"), float64(1)) +// a.Greaterf("b", "a", "error message %s", "formatted") +func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Greaterf(a.t, e1, e2, msg, args...) +} + // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // @@ -589,6 +639,56 @@ func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...in return Lenf(a.t, object, length, msg, args...) } +// Less asserts that the first element in less than the second +// +// a.Less(1, 2) +// a.Less(float64(1), float64(2)) +// a.Less("a", "b") +func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Less(a.t, e1, e2, msgAndArgs...) +} + +// LessOrEqual asserts that the first element in greater or equal than the second +// +// a.LessOrEqual(1, 2) +// a.LessOrEqual(2, 2) +// a.LessOrEqual("a", "b") +// a.LessOrEqual("b", "b") +func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return LessOrEqual(a.t, e1, e2, msgAndArgs...) +} + +// LessOrEqualf asserts that the first element in greater or equal than the second +// +// a.LessOrEqualf(1, 2, "error message %s", "formatted") +// a.LessOrEqualf(2, 2, "error message %s", "formatted") +// a.LessOrEqualf("a", "b", "error message %s", "formatted") +// a.LessOrEqualf("b", "b", "error message %s", "formatted") +func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return LessOrEqualf(a.t, e1, e2, msg, args...) +} + +// Lessf asserts that the first element in less than the second +// +// a.Lessf(1, 2, "error message %s", "formatted") +// a.Lessf(float64(1, "error message %s", "formatted"), float64(2)) +// a.Lessf("a", "b", "error message %s", "formatted") +func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Lessf(a.t, e1, e2, msg, args...) +} + // Nil asserts that the specified object is nil. // // a.Nil(err) @@ -877,6 +977,32 @@ func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args . return Regexpf(a.t, rx, str, msg, args...) } +// Same asserts that two pointers reference the same object. +// +// a.Same(ptr1, ptr2) +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Same(a.t, expected, actual, msgAndArgs...) +} + +// Samef asserts that two pointers reference the same object. +// +// a.Samef(ptr1, ptr2, "error message %s", "formatted") +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Samef(a.t, expected, actual, msg, args...) +} + // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go new file mode 100644 index 000000000..8c4f347f9 --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/assertion_order.go @@ -0,0 +1,309 @@ +package assert + +import ( + "fmt" + "reflect" +) + +func compare(obj1, obj2 interface{}, kind reflect.Kind) (int, bool) { + switch kind { + case reflect.Int: + { + intobj1 := obj1.(int) + intobj2 := obj2.(int) + if intobj1 > intobj2 { + return -1, true + } + if intobj1 == intobj2 { + return 0, true + } + if intobj1 < intobj2 { + return 1, true + } + } + case reflect.Int8: + { + int8obj1 := obj1.(int8) + int8obj2 := obj2.(int8) + if int8obj1 > int8obj2 { + return -1, true + } + if int8obj1 == int8obj2 { + return 0, true + } + if int8obj1 < int8obj2 { + return 1, true + } + } + case reflect.Int16: + { + int16obj1 := obj1.(int16) + int16obj2 := obj2.(int16) + if int16obj1 > int16obj2 { + return -1, true + } + if int16obj1 == int16obj2 { + return 0, true + } + if int16obj1 < int16obj2 { + return 1, true + } + } + case reflect.Int32: + { + int32obj1 := obj1.(int32) + int32obj2 := obj2.(int32) + if int32obj1 > int32obj2 { + return -1, true + } + if int32obj1 == int32obj2 { + return 0, true + } + if int32obj1 < int32obj2 { + return 1, true + } + } + case reflect.Int64: + { + int64obj1 := obj1.(int64) + int64obj2 := obj2.(int64) + if int64obj1 > int64obj2 { + return -1, true + } + if int64obj1 == int64obj2 { + return 0, true + } + if int64obj1 < int64obj2 { + return 1, true + } + } + case reflect.Uint: + { + uintobj1 := obj1.(uint) + uintobj2 := obj2.(uint) + if uintobj1 > uintobj2 { + return -1, true + } + if uintobj1 == uintobj2 { + return 0, true + } + if uintobj1 < uintobj2 { + return 1, true + } + } + case reflect.Uint8: + { + uint8obj1 := obj1.(uint8) + uint8obj2 := obj2.(uint8) + if uint8obj1 > uint8obj2 { + return -1, true + } + if uint8obj1 == uint8obj2 { + return 0, true + } + if uint8obj1 < uint8obj2 { + return 1, true + } + } + case reflect.Uint16: + { + uint16obj1 := obj1.(uint16) + uint16obj2 := obj2.(uint16) + if uint16obj1 > uint16obj2 { + return -1, true + } + if uint16obj1 == uint16obj2 { + return 0, true + } + if uint16obj1 < uint16obj2 { + return 1, true + } + } + case reflect.Uint32: + { + uint32obj1 := obj1.(uint32) + uint32obj2 := obj2.(uint32) + if uint32obj1 > uint32obj2 { + return -1, true + } + if uint32obj1 == uint32obj2 { + return 0, true + } + if uint32obj1 < uint32obj2 { + return 1, true + } + } + case reflect.Uint64: + { + uint64obj1 := obj1.(uint64) + uint64obj2 := obj2.(uint64) + if uint64obj1 > uint64obj2 { + return -1, true + } + if uint64obj1 == uint64obj2 { + return 0, true + } + if uint64obj1 < uint64obj2 { + return 1, true + } + } + case reflect.Float32: + { + float32obj1 := obj1.(float32) + float32obj2 := obj2.(float32) + if float32obj1 > float32obj2 { + return -1, true + } + if float32obj1 == float32obj2 { + return 0, true + } + if float32obj1 < float32obj2 { + return 1, true + } + } + case reflect.Float64: + { + float64obj1 := obj1.(float64) + float64obj2 := obj2.(float64) + if float64obj1 > float64obj2 { + return -1, true + } + if float64obj1 == float64obj2 { + return 0, true + } + if float64obj1 < float64obj2 { + return 1, true + } + } + case reflect.String: + { + stringobj1 := obj1.(string) + stringobj2 := obj2.(string) + if stringobj1 > stringobj2 { + return -1, true + } + if stringobj1 == stringobj2 { + return 0, true + } + if stringobj1 < stringobj2 { + return 1, true + } + } + } + + return 0, false +} + +// Greater asserts that the first element is greater than the second +// +// assert.Greater(t, 2, 1) +// assert.Greater(t, float64(2), float64(1)) +// assert.Greater(t, "b", "a") +func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + e1Kind := reflect.ValueOf(e1).Kind() + e2Kind := reflect.ValueOf(e2).Kind() + if e1Kind != e2Kind { + return Fail(t, "Elements should be the same type", msgAndArgs...) + } + + res, isComparable := compare(e1, e2, e1Kind) + if !isComparable { + return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...) + } + + if res != -1 { + return Fail(t, fmt.Sprintf("\"%s\" is not greater than \"%s\"", e1, e2), msgAndArgs...) + } + + return true +} + +// GreaterOrEqual asserts that the first element in greater or equal than the second +// +// assert.GreaterOrEqual(t, 2, 1) +// assert.GreaterOrEqual(t, 2, 2) +// assert.GreaterOrEqual(t, "b", "a") +// assert.GreaterOrEqual(t, "b", "b") +func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + e1Kind := reflect.ValueOf(e1).Kind() + e2Kind := reflect.ValueOf(e2).Kind() + if e1Kind != e2Kind { + return Fail(t, "Elements should be the same type", msgAndArgs...) + } + + res, isComparable := compare(e1, e2, e1Kind) + if !isComparable { + return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...) + } + + if res != -1 && res != 0 { + return Fail(t, fmt.Sprintf("\"%s\" is not greater or equal than \"%s\"", e1, e2), msgAndArgs...) + } + + return true +} + +// Less asserts that the first element in less than the second +// +// assert.Less(t, 1, 2) +// assert.Less(t, float64(1), float64(2)) +// assert.Less(t, "a", "b") +func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + e1Kind := reflect.ValueOf(e1).Kind() + e2Kind := reflect.ValueOf(e2).Kind() + if e1Kind != e2Kind { + return Fail(t, "Elements should be the same type", msgAndArgs...) + } + + res, isComparable := compare(e1, e2, e1Kind) + if !isComparable { + return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...) + } + + if res != 1 { + return Fail(t, fmt.Sprintf("\"%s\" is not less than \"%s\"", e1, e2), msgAndArgs...) + } + + return true +} + +// LessOrEqual asserts that the first element in greater or equal than the second +// +// assert.LessOrEqual(t, 1, 2) +// assert.LessOrEqual(t, 2, 2) +// assert.LessOrEqual(t, "a", "b") +// assert.LessOrEqual(t, "b", "b") +func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + e1Kind := reflect.ValueOf(e1).Kind() + e2Kind := reflect.ValueOf(e2).Kind() + if e1Kind != e2Kind { + return Fail(t, "Elements should be the same type", msgAndArgs...) + } + + res, isComparable := compare(e1, e2, e1Kind) + if !isComparable { + return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...) + } + + if res != 1 && res != 0 { + return Fail(t, fmt.Sprintf("\"%s\" is not less or equal than \"%s\"", e1, e2), msgAndArgs...) + } + + return true +} diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index 9bd4a80e4..eb3b39baf 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -350,6 +350,37 @@ func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) } +// Same asserts that two pointers reference the same object. +// +// assert.Same(t, ptr1, ptr2) +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + expectedPtr, actualPtr := reflect.ValueOf(expected), reflect.ValueOf(actual) + if expectedPtr.Kind() != reflect.Ptr || actualPtr.Kind() != reflect.Ptr { + return Fail(t, "Invalid operation: both arguments must be pointers", msgAndArgs...) + } + + expectedType, actualType := reflect.TypeOf(expected), reflect.TypeOf(actual) + if expectedType != actualType { + return Fail(t, fmt.Sprintf("Pointer expected to be of type %v, but was %v", + expectedType, actualType), msgAndArgs...) + } + + if expected != actual { + return Fail(t, fmt.Sprintf("Not same: \n"+ + "expected: %p %#v\n"+ + "actual : %p %#v", expected, expected, actual, actual), msgAndArgs...) + } + + return true +} + // formatUnequalValues takes two values of arbitrary types and returns string // representations appropriate to be presented to the user. // @@ -629,7 +660,7 @@ func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{ func includeElement(list interface{}, element interface{}) (ok, found bool) { listValue := reflect.ValueOf(list) - elementValue := reflect.ValueOf(element) + listKind := reflect.TypeOf(list).Kind() defer func() { if e := recover(); e != nil { ok = false @@ -637,11 +668,12 @@ func includeElement(list interface{}, element interface{}) (ok, found bool) { } }() - if reflect.TypeOf(list).Kind() == reflect.String { + if listKind == reflect.String { + elementValue := reflect.ValueOf(element) return true, strings.Contains(listValue.String(), elementValue.String()) } - if reflect.TypeOf(list).Kind() == reflect.Map { + if listKind == reflect.Map { mapKeys := listValue.MapKeys() for i := 0; i < len(mapKeys); i++ { if ObjectsAreEqual(mapKeys[i].Interface(), element) { diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go index 535f29349..5491907f6 100644 --- a/vendor/github.com/stretchr/testify/require/require.go +++ b/vendor/github.com/stretchr/testify/require/require.go @@ -14,23 +14,23 @@ import ( // Condition uses a Comparison to assert a complex condition. func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) { - if assert.Condition(t, comp, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Condition(t, comp, msgAndArgs...) { + return + } t.FailNow() } // Conditionf uses a Comparison to assert a complex condition. func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) { - if assert.Conditionf(t, comp, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Conditionf(t, comp, msg, args...) { + return + } t.FailNow() } @@ -41,12 +41,12 @@ func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interfac // assert.Contains(t, ["Hello", "World"], "World") // assert.Contains(t, {"Hello": "World"}, "Hello") func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if assert.Contains(t, s, contains, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Contains(t, s, contains, msgAndArgs...) { + return + } t.FailNow() } @@ -57,34 +57,34 @@ func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...int // assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") // assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { - if assert.Containsf(t, s, contains, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Containsf(t, s, contains, msg, args...) { + return + } t.FailNow() } // DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. func DirExists(t TestingT, path string, msgAndArgs ...interface{}) { - if assert.DirExists(t, path, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.DirExists(t, path, msgAndArgs...) { + return + } t.FailNow() } // DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. func DirExistsf(t TestingT, path string, msg string, args ...interface{}) { - if assert.DirExistsf(t, path, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.DirExistsf(t, path, msg, args...) { + return + } t.FailNow() } @@ -94,12 +94,12 @@ func DirExistsf(t TestingT, path string, msg string, args ...interface{}) { // // assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) { - if assert.ElementsMatch(t, listA, listB, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.ElementsMatch(t, listA, listB, msgAndArgs...) { + return + } t.FailNow() } @@ -109,12 +109,12 @@ func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs // // assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) { - if assert.ElementsMatchf(t, listA, listB, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.ElementsMatchf(t, listA, listB, msg, args...) { + return + } t.FailNow() } @@ -123,12 +123,12 @@ func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string // // assert.Empty(t, obj) func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.Empty(t, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Empty(t, object, msgAndArgs...) { + return + } t.FailNow() } @@ -137,12 +137,12 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { // // assert.Emptyf(t, obj, "error message %s", "formatted") func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.Emptyf(t, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Emptyf(t, object, msg, args...) { + return + } t.FailNow() } @@ -154,12 +154,12 @@ func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { // referenced values (as opposed to the memory addresses). Function equality // cannot be determined and will always fail. func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.Equal(t, expected, actual, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Equal(t, expected, actual, msgAndArgs...) { + return + } t.FailNow() } @@ -169,12 +169,12 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...i // actualObj, err := SomeFunction() // assert.EqualError(t, err, expectedErrorString) func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { - if assert.EqualError(t, theError, errString, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.EqualError(t, theError, errString, msgAndArgs...) { + return + } t.FailNow() } @@ -184,12 +184,12 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte // actualObj, err := SomeFunction() // assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) { - if assert.EqualErrorf(t, theError, errString, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.EqualErrorf(t, theError, errString, msg, args...) { + return + } t.FailNow() } @@ -198,12 +198,12 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args // // assert.EqualValues(t, uint32(123), int32(123)) func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.EqualValues(t, expected, actual, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.EqualValues(t, expected, actual, msgAndArgs...) { + return + } t.FailNow() } @@ -212,12 +212,12 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg // // assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.EqualValuesf(t, expected, actual, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.EqualValuesf(t, expected, actual, msg, args...) { + return + } t.FailNow() } @@ -229,12 +229,12 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri // referenced values (as opposed to the memory addresses). Function equality // cannot be determined and will always fail. func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.Equalf(t, expected, actual, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Equalf(t, expected, actual, msg, args...) { + return + } t.FailNow() } @@ -245,12 +245,12 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar // assert.Equal(t, expectedError, err) // } func Error(t TestingT, err error, msgAndArgs ...interface{}) { - if assert.Error(t, err, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Error(t, err, msgAndArgs...) { + return + } t.FailNow() } @@ -261,12 +261,12 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) { // assert.Equal(t, expectedErrorf, err) // } func Errorf(t TestingT, err error, msg string, args ...interface{}) { - if assert.Errorf(t, err, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Errorf(t, err, msg, args...) { + return + } t.FailNow() } @@ -274,12 +274,12 @@ func Errorf(t TestingT, err error, msg string, args ...interface{}) { // // assert.Exactly(t, int32(123), int64(123)) func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.Exactly(t, expected, actual, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Exactly(t, expected, actual, msgAndArgs...) { + return + } t.FailNow() } @@ -287,56 +287,56 @@ func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs .. // // assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.Exactlyf(t, expected, actual, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Exactlyf(t, expected, actual, msg, args...) { + return + } t.FailNow() } // Fail reports a failure through func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) { - if assert.Fail(t, failureMessage, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Fail(t, failureMessage, msgAndArgs...) { + return + } t.FailNow() } // FailNow fails test func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) { - if assert.FailNow(t, failureMessage, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.FailNow(t, failureMessage, msgAndArgs...) { + return + } t.FailNow() } // FailNowf fails test func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) { - if assert.FailNowf(t, failureMessage, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.FailNowf(t, failureMessage, msg, args...) { + return + } t.FailNow() } // Failf reports a failure through func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { - if assert.Failf(t, failureMessage, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Failf(t, failureMessage, msg, args...) { + return + } t.FailNow() } @@ -344,12 +344,12 @@ func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { // // assert.False(t, myBool) func False(t TestingT, value bool, msgAndArgs ...interface{}) { - if assert.False(t, value, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.False(t, value, msgAndArgs...) { + return + } t.FailNow() } @@ -357,34 +357,96 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) { // // assert.Falsef(t, myBool, "error message %s", "formatted") func Falsef(t TestingT, value bool, msg string, args ...interface{}) { - if assert.Falsef(t, value, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Falsef(t, value, msg, args...) { + return + } t.FailNow() } // FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. func FileExists(t TestingT, path string, msgAndArgs ...interface{}) { - if assert.FileExists(t, path, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.FileExists(t, path, msgAndArgs...) { + return + } t.FailNow() } // FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } if assert.FileExistsf(t, path, msg, args...) { return } + t.FailNow() +} + +// Greater asserts that the first element is greater than the second +// +// assert.Greater(t, 2, 1) +// assert.Greater(t, float64(2), float64(1)) +// assert.Greater(t, "b", "a") +func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Greater(t, e1, e2, msgAndArgs...) { + return + } + t.FailNow() +} + +// GreaterOrEqual asserts that the first element in greater or equal than the second +// +// assert.GreaterOrEqual(t, 2, 1) +// assert.GreaterOrEqual(t, 2, 2) +// assert.GreaterOrEqual(t, "b", "a") +// assert.GreaterOrEqual(t, "b", "b") +func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.GreaterOrEqual(t, e1, e2, msgAndArgs...) { + return + } + t.FailNow() +} + +// GreaterOrEqualf asserts that the first element in greater or equal than the second +// +// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") +func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.GreaterOrEqualf(t, e1, e2, msg, args...) { + return + } + t.FailNow() +} + +// Greaterf asserts that the first element is greater than the second +// +// assert.Greaterf(t, 2, 1, "error message %s", "formatted") +// assert.Greaterf(t, float64(2, "error message %s", "formatted"), float64(1)) +// assert.Greaterf(t, "b", "a", "error message %s", "formatted") +func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.Greaterf(t, e1, e2, msg, args...) { + return + } t.FailNow() } @@ -395,12 +457,12 @@ func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) { + return + } t.FailNow() } @@ -411,12 +473,12 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url s // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) { + return + } t.FailNow() } @@ -427,12 +489,12 @@ func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) { + return + } t.FailNow() } @@ -443,12 +505,12 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, ur // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) { + return + } t.FailNow() } @@ -458,12 +520,12 @@ func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, u // // Returns whether the assertion was successful (true) or not (false). func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) { + return + } t.FailNow() } @@ -473,12 +535,12 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, // // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) { + return + } t.FailNow() } @@ -488,12 +550,12 @@ func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, // // Returns whether the assertion was successful (true) or not (false). func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) { + return + } t.FailNow() } @@ -503,12 +565,12 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url strin // // Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) { + return + } t.FailNow() } @@ -518,12 +580,12 @@ func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url stri // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { + return + } t.FailNow() } @@ -533,12 +595,12 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { + return + } t.FailNow() } @@ -546,12 +608,12 @@ func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url strin // // assert.Implements(t, (*MyInterface)(nil), new(MyObject)) func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { - if assert.Implements(t, interfaceObject, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Implements(t, interfaceObject, object, msgAndArgs...) { + return + } t.FailNow() } @@ -559,12 +621,12 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg // // assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { - if assert.Implementsf(t, interfaceObject, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Implementsf(t, interfaceObject, object, msg, args...) { + return + } t.FailNow() } @@ -572,56 +634,56 @@ func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, ms // // assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { + return + } t.FailNow() } // InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { + return + } t.FailNow() } // InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { + return + } t.FailNow() } // InDeltaSlice is the same as InDelta, except it compares two slices. func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { + return + } t.FailNow() } // InDeltaSlicef is the same as InDelta, except it compares two slices. func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { + return + } t.FailNow() } @@ -629,78 +691,78 @@ func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta f // // assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaf(t, expected, actual, delta, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InDeltaf(t, expected, actual, delta, msg, args...) { + return + } t.FailNow() } // InEpsilon asserts that expected and actual have a relative error less than epsilon func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { + return + } t.FailNow() } // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { + return + } t.FailNow() } // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { + return + } t.FailNow() } // InEpsilonf asserts that expected and actual have a relative error less than epsilon func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { + return + } t.FailNow() } // IsType asserts that the specified objects are of the same type. func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { - if assert.IsType(t, expectedType, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.IsType(t, expectedType, object, msgAndArgs...) { + return + } t.FailNow() } // IsTypef asserts that the specified objects are of the same type. func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) { - if assert.IsTypef(t, expectedType, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.IsTypef(t, expectedType, object, msg, args...) { + return + } t.FailNow() } @@ -708,12 +770,12 @@ func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg strin // // assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { - if assert.JSONEq(t, expected, actual, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.JSONEq(t, expected, actual, msgAndArgs...) { + return + } t.FailNow() } @@ -721,12 +783,12 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{ // // assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { - if assert.JSONEqf(t, expected, actual, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.JSONEqf(t, expected, actual, msg, args...) { + return + } t.FailNow() } @@ -735,12 +797,12 @@ func JSONEqf(t TestingT, expected string, actual string, msg string, args ...int // // assert.Len(t, mySlice, 3) func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { - if assert.Len(t, object, length, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Len(t, object, length, msgAndArgs...) { + return + } t.FailNow() } @@ -749,12 +811,74 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) // // assert.Lenf(t, mySlice, 3, "error message %s", "formatted") func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } if assert.Lenf(t, object, length, msg, args...) { return } + t.FailNow() +} + +// Less asserts that the first element in less than the second +// +// assert.Less(t, 1, 2) +// assert.Less(t, float64(1), float64(2)) +// assert.Less(t, "a", "b") +func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Less(t, e1, e2, msgAndArgs...) { + return + } + t.FailNow() +} + +// LessOrEqual asserts that the first element in greater or equal than the second +// +// assert.LessOrEqual(t, 1, 2) +// assert.LessOrEqual(t, 2, 2) +// assert.LessOrEqual(t, "a", "b") +// assert.LessOrEqual(t, "b", "b") +func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.LessOrEqual(t, e1, e2, msgAndArgs...) { + return + } + t.FailNow() +} + +// LessOrEqualf asserts that the first element in greater or equal than the second +// +// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") +func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.LessOrEqualf(t, e1, e2, msg, args...) { + return + } + t.FailNow() +} + +// Lessf asserts that the first element in less than the second +// +// assert.Lessf(t, 1, 2, "error message %s", "formatted") +// assert.Lessf(t, float64(1, "error message %s", "formatted"), float64(2)) +// assert.Lessf(t, "a", "b", "error message %s", "formatted") +func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.Lessf(t, e1, e2, msg, args...) { + return + } t.FailNow() } @@ -762,12 +886,12 @@ func Lenf(t TestingT, object interface{}, length int, msg string, args ...interf // // assert.Nil(t, err) func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.Nil(t, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Nil(t, object, msgAndArgs...) { + return + } t.FailNow() } @@ -775,12 +899,12 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { // // assert.Nilf(t, err, "error message %s", "formatted") func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.Nilf(t, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Nilf(t, object, msg, args...) { + return + } t.FailNow() } @@ -791,12 +915,12 @@ func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { // assert.Equal(t, expectedObj, actualObj) // } func NoError(t TestingT, err error, msgAndArgs ...interface{}) { - if assert.NoError(t, err, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NoError(t, err, msgAndArgs...) { + return + } t.FailNow() } @@ -807,12 +931,12 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) { // assert.Equal(t, expectedObj, actualObj) // } func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { - if assert.NoErrorf(t, err, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NoErrorf(t, err, msg, args...) { + return + } t.FailNow() } @@ -823,12 +947,12 @@ func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { // assert.NotContains(t, ["Hello", "World"], "Earth") // assert.NotContains(t, {"Hello": "World"}, "Earth") func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if assert.NotContains(t, s, contains, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotContains(t, s, contains, msgAndArgs...) { + return + } t.FailNow() } @@ -839,12 +963,12 @@ func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ... // assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") // assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { - if assert.NotContainsf(t, s, contains, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotContainsf(t, s, contains, msg, args...) { + return + } t.FailNow() } @@ -855,12 +979,12 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a // assert.Equal(t, "two", obj[1]) // } func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.NotEmpty(t, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotEmpty(t, object, msgAndArgs...) { + return + } t.FailNow() } @@ -871,12 +995,12 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { // assert.Equal(t, "two", obj[1]) // } func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.NotEmptyf(t, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotEmptyf(t, object, msg, args...) { + return + } t.FailNow() } @@ -887,12 +1011,12 @@ func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.NotEqual(t, expected, actual, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotEqual(t, expected, actual, msgAndArgs...) { + return + } t.FailNow() } @@ -903,12 +1027,12 @@ func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs . // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.NotEqualf(t, expected, actual, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotEqualf(t, expected, actual, msg, args...) { + return + } t.FailNow() } @@ -916,12 +1040,12 @@ func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, // // assert.NotNil(t, err) func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.NotNil(t, object, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotNil(t, object, msgAndArgs...) { + return + } t.FailNow() } @@ -929,12 +1053,12 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { // // assert.NotNilf(t, err, "error message %s", "formatted") func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.NotNilf(t, object, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotNilf(t, object, msg, args...) { + return + } t.FailNow() } @@ -942,12 +1066,12 @@ func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { // // assert.NotPanics(t, func(){ RemainCalm() }) func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.NotPanics(t, f, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotPanics(t, f, msgAndArgs...) { + return + } t.FailNow() } @@ -955,12 +1079,12 @@ func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { // // assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.NotPanicsf(t, f, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotPanicsf(t, f, msg, args...) { + return + } t.FailNow() } @@ -969,12 +1093,12 @@ func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interfac // assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // assert.NotRegexp(t, "^start", "it's not starting") func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if assert.NotRegexp(t, rx, str, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotRegexp(t, rx, str, msgAndArgs...) { + return + } t.FailNow() } @@ -983,12 +1107,12 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf // assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") // assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { - if assert.NotRegexpf(t, rx, str, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotRegexpf(t, rx, str, msg, args...) { + return + } t.FailNow() } @@ -997,12 +1121,12 @@ func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args .. // // assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if assert.NotSubset(t, list, subset, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotSubset(t, list, subset, msgAndArgs...) { + return + } t.FailNow() } @@ -1011,34 +1135,34 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i // // assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { - if assert.NotSubsetf(t, list, subset, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotSubsetf(t, list, subset, msg, args...) { + return + } t.FailNow() } // NotZero asserts that i is not the zero value for its type. func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) { - if assert.NotZero(t, i, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotZero(t, i, msgAndArgs...) { + return + } t.FailNow() } // NotZerof asserts that i is not the zero value for its type. func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { - if assert.NotZerof(t, i, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.NotZerof(t, i, msg, args...) { + return + } t.FailNow() } @@ -1046,12 +1170,12 @@ func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { // // assert.Panics(t, func(){ GoCrazy() }) func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.Panics(t, f, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Panics(t, f, msgAndArgs...) { + return + } t.FailNow() } @@ -1060,12 +1184,12 @@ func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { // // assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { + return + } t.FailNow() } @@ -1074,12 +1198,12 @@ func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, m // // assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.PanicsWithValuef(t, expected, f, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.PanicsWithValuef(t, expected, f, msg, args...) { + return + } t.FailNow() } @@ -1087,12 +1211,12 @@ func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, // // assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.Panicsf(t, f, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Panicsf(t, f, msg, args...) { + return + } t.FailNow() } @@ -1101,12 +1225,12 @@ func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{} // assert.Regexp(t, regexp.MustCompile("start"), "it's starting") // assert.Regexp(t, "start...$", "it's not starting") func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if assert.Regexp(t, rx, str, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Regexp(t, rx, str, msgAndArgs...) { + return + } t.FailNow() } @@ -1115,12 +1239,44 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") // assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } if assert.Regexpf(t, rx, str, msg, args...) { return } + t.FailNow() +} + +// Same asserts that two pointers reference the same object. +// +// assert.Same(t, ptr1, ptr2) +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Same(t, expected, actual, msgAndArgs...) { + return + } + t.FailNow() +} + +// Samef asserts that two pointers reference the same object. +// +// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.Samef(t, expected, actual, msg, args...) { + return + } t.FailNow() } @@ -1129,12 +1285,12 @@ func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...in // // assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if assert.Subset(t, list, subset, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Subset(t, list, subset, msgAndArgs...) { + return + } t.FailNow() } @@ -1143,12 +1299,12 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte // // assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { - if assert.Subsetf(t, list, subset, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Subsetf(t, list, subset, msg, args...) { + return + } t.FailNow() } @@ -1156,12 +1312,12 @@ func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args // // assert.True(t, myBool) func True(t TestingT, value bool, msgAndArgs ...interface{}) { - if assert.True(t, value, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.True(t, value, msgAndArgs...) { + return + } t.FailNow() } @@ -1169,12 +1325,12 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) { // // assert.Truef(t, myBool, "error message %s", "formatted") func Truef(t TestingT, value bool, msg string, args ...interface{}) { - if assert.Truef(t, value, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Truef(t, value, msg, args...) { + return + } t.FailNow() } @@ -1182,12 +1338,12 @@ func Truef(t TestingT, value bool, msg string, args ...interface{}) { // // assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { - if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { + return + } t.FailNow() } @@ -1195,33 +1351,33 @@ func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time // // assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { - if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { + return + } t.FailNow() } // Zero asserts that i is the zero value for its type. func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) { - if assert.Zero(t, i, msgAndArgs...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Zero(t, i, msgAndArgs...) { + return + } t.FailNow() } // Zerof asserts that i is the zero value for its type. func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) { - if assert.Zerof(t, i, msg, args...) { - return - } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.Zerof(t, i, msg, args...) { + return + } t.FailNow() } diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl index 6ffc751b5..55e42ddeb 100644 --- a/vendor/github.com/stretchr/testify/require/require.go.tmpl +++ b/vendor/github.com/stretchr/testify/require/require.go.tmpl @@ -1,6 +1,6 @@ {{.Comment}} func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { - if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } if h, ok := t.(tHelper); ok { h.Helper() } + if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } t.FailNow() } diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go index 9fe41dbdc..1637c6c06 100644 --- a/vendor/github.com/stretchr/testify/require/require_forward.go +++ b/vendor/github.com/stretchr/testify/require/require_forward.go @@ -304,6 +304,56 @@ func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) { FileExistsf(a.t, path, msg, args...) } +// Greater asserts that the first element is greater than the second +// +// a.Greater(2, 1) +// a.Greater(float64(2), float64(1)) +// a.Greater("b", "a") +func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Greater(a.t, e1, e2, msgAndArgs...) +} + +// GreaterOrEqual asserts that the first element in greater or equal than the second +// +// a.GreaterOrEqual(2, 1) +// a.GreaterOrEqual(2, 2) +// a.GreaterOrEqual("b", "a") +// a.GreaterOrEqual("b", "b") +func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + GreaterOrEqual(a.t, e1, e2, msgAndArgs...) +} + +// GreaterOrEqualf asserts that the first element in greater or equal than the second +// +// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") +// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") +// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") +// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") +func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + GreaterOrEqualf(a.t, e1, e2, msg, args...) +} + +// Greaterf asserts that the first element is greater than the second +// +// a.Greaterf(2, 1, "error message %s", "formatted") +// a.Greaterf(float64(2, "error message %s", "formatted"), float64(1)) +// a.Greaterf("b", "a", "error message %s", "formatted") +func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Greaterf(a.t, e1, e2, msg, args...) +} + // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // @@ -590,6 +640,56 @@ func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...in Lenf(a.t, object, length, msg, args...) } +// Less asserts that the first element in less than the second +// +// a.Less(1, 2) +// a.Less(float64(1), float64(2)) +// a.Less("a", "b") +func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Less(a.t, e1, e2, msgAndArgs...) +} + +// LessOrEqual asserts that the first element in greater or equal than the second +// +// a.LessOrEqual(1, 2) +// a.LessOrEqual(2, 2) +// a.LessOrEqual("a", "b") +// a.LessOrEqual("b", "b") +func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + LessOrEqual(a.t, e1, e2, msgAndArgs...) +} + +// LessOrEqualf asserts that the first element in greater or equal than the second +// +// a.LessOrEqualf(1, 2, "error message %s", "formatted") +// a.LessOrEqualf(2, 2, "error message %s", "formatted") +// a.LessOrEqualf("a", "b", "error message %s", "formatted") +// a.LessOrEqualf("b", "b", "error message %s", "formatted") +func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + LessOrEqualf(a.t, e1, e2, msg, args...) +} + +// Lessf asserts that the first element in less than the second +// +// a.Lessf(1, 2, "error message %s", "formatted") +// a.Lessf(float64(1, "error message %s", "formatted"), float64(2)) +// a.Lessf("a", "b", "error message %s", "formatted") +func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Lessf(a.t, e1, e2, msg, args...) +} + // Nil asserts that the specified object is nil. // // a.Nil(err) @@ -878,6 +978,32 @@ func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args . Regexpf(a.t, rx, str, msg, args...) } +// Same asserts that two pointers reference the same object. +// +// a.Same(ptr1, ptr2) +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Same(a.t, expected, actual, msgAndArgs...) +} + +// Samef asserts that two pointers reference the same object. +// +// a.Samef(ptr1, ptr2, "error message %s", "formatted") +// +// Both arguments must be pointer variables. Pointer variable sameness is +// determined based on the equality of both type and value. +func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Samef(a.t, expected, actual, msg, args...) +} + // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // diff --git a/vendor/github.com/yunify/qingstor-sdk-go/.travis.yml b/vendor/github.com/yunify/qingstor-sdk-go/.travis.yml deleted file mode 100644 index 1f96d31fd..000000000 --- a/vendor/github.com/yunify/qingstor-sdk-go/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -sudo: required - -services: - - docker - -language: go -go: - - master - - 1.9 - - 1.8 - - 1.7 - -cache: - directories: - - ${HOME}/source - -before_install: - - pushd ${HOME}/source - - if [[ ! -d "./make-4.0" ]]; then - wget http://ftp.gnu.org/gnu/make/make-4.0.tar.gz && - tar -vxzf make-4.0.tar.gz && - pushd make-4.0 && ./configure && make && popd; - fi - - pushd make-4.0 && sudo make install && popd - - if [[ ! -d "./glide-v0.12.3" ]]; then - wget https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz && - tar -vxzf glide-v0.12.3-linux-amd64.tar.gz && - mv linux-amd64 glide-v0.12.3; - fi - - pushd glide-v0.12.3 && sudo cp glide /usr/local/bin && popd - - if [[ ! -d "./snips-v0.2.8" ]]; then - wget https://github.com/yunify/snips/releases/download/v0.2.8/snips-v0.2.8-linux_amd64.tar.gz && - mkdir snips-v0.2.8 && - pushd snips-v0.2.8 && - tar -vxzf ../snips-v0.2.8-linux_amd64.tar.gz && - popd; - fi - - pushd snips-v0.2.8 && sudo cp snips /usr/local/bin && popd - - popd - - /usr/local/bin/make --version - - /usr/local/bin/glide --version - -install: - - go get -u github.com/golang/lint/golint; - - glide install - - git submodule init - -before_script: - - /usr/local/bin/make update - - /usr/local/bin/make generate - -script: - - /usr/local/bin/make check - - /usr/local/bin/make release - - /usr/local/bin/make build test test-coverage diff --git a/vendor/github.com/yunify/qingstor-sdk-go/MAINTAINERS b/vendor/github.com/yunify/qingstor-sdk-go/MAINTAINERS deleted file mode 100644 index a9e08e815..000000000 --- a/vendor/github.com/yunify/qingstor-sdk-go/MAINTAINERS +++ /dev/null @@ -1 +0,0 @@ -Jingwen Peng diff --git a/vendor/github.com/yunify/qingstor-sdk-go/glide.lock b/vendor/github.com/yunify/qingstor-sdk-go/glide.lock deleted file mode 100644 index 5c0f31055..000000000 --- a/vendor/github.com/yunify/qingstor-sdk-go/glide.lock +++ /dev/null @@ -1,32 +0,0 @@ -hash: 6e1d4e547cdd58944ef920192480d29edd118cac0e8269d793315066d1249b4e -updated: 2018-07-16T14:42:51.093308+08:00 -imports: -- name: github.com/pengsrc/go-shared - version: db9bcfc423552eef790d989bb81ef055d0d26286 - subpackages: - - buffer - - check - - convert - - log - - reopen -- name: gopkg.in/yaml.v2 - version: 287cf08546ab5e7e37d55a84f7ed3fd1db036de5 - repo: https://github.com/go-yaml/yaml.git -testImports: -- name: github.com/DATA-DOG/godog - version: 623ff9946e5c72834c19a019a153b8e3a338a52c - subpackages: - - colors - - gherkin -- name: github.com/davecgh/go-spew - version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9 - subpackages: - - spew -- name: github.com/pmezard/go-difflib - version: d8ed2627bdf02c080bf22230dbb337003b7aba2d - subpackages: - - difflib -- name: github.com/stretchr/testify - version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0 - subpackages: - - assert diff --git a/vendor/github.com/yunify/qingstor-sdk-go/glide.yaml b/vendor/github.com/yunify/qingstor-sdk-go/glide.yaml deleted file mode 100644 index 50f910204..000000000 --- a/vendor/github.com/yunify/qingstor-sdk-go/glide.yaml +++ /dev/null @@ -1,11 +0,0 @@ -package: github.com/yunify/qingstor-sdk-go -import: - -# YAML -- package: gopkg.in/yaml.v2 - version: 287cf08546ab5e7e37d55a84f7ed3fd1db036de5 - repo: https://github.com/go-yaml/yaml.git - -# Shared packages -- package: github.com/pengsrc/go-shared - version: db9bcfc423552eef790d989bb81ef055d0d26286 diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/builder/qingstor.go b/vendor/github.com/yunify/qingstor-sdk-go/request/builder/qingstor.go deleted file mode 100644 index 78b28c3fb..000000000 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/builder/qingstor.go +++ /dev/null @@ -1,163 +0,0 @@ -// +------------------------------------------------------------------------- -// | Copyright (C) 2016 Yunify, Inc. -// +------------------------------------------------------------------------- -// | Licensed under the Apache License, Version 2.0 (the "License"); -// | you may not use this work except in compliance with the License. -// | You may obtain a copy of the License in the LICENSE file, or at: -// | -// | http://www.apache.org/licenses/LICENSE-2.0 -// | -// | Unless required by applicable law or agreed to in writing, software -// | distributed under the License is distributed on an "AS IS" BASIS, -// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// | See the License for the specific language governing permissions and -// | limitations under the License. -// +------------------------------------------------------------------------- - -package builder - -import ( - "bytes" - "crypto/md5" - "encoding/base64" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "reflect" - "regexp" - "runtime" - "strconv" - "strings" - - "github.com/pengsrc/go-shared/convert" - - "github.com/yunify/qingstor-sdk-go" - "github.com/yunify/qingstor-sdk-go/logger" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/utils" -) - -// QingStorBuilder is the request builder for QingStor service. -type QingStorBuilder struct { - baseBuilder *BaseBuilder -} - -// BuildHTTPRequest builds http request with an operation and an input. -func (qb *QingStorBuilder) BuildHTTPRequest(o *data.Operation, i *reflect.Value) (*http.Request, error) { - qb.baseBuilder = &BaseBuilder{} - qb.baseBuilder.operation = o - qb.baseBuilder.input = i - - _, err := qb.baseBuilder.parse() - if err != nil { - return nil, err - } - err = qb.parseURL() - if err != nil { - return nil, err - } - - httpRequest, err := http.NewRequest(qb.baseBuilder.operation.RequestMethod, - qb.baseBuilder.parsedURL, qb.baseBuilder.parsedBody) - if err != nil { - return nil, err - } - - err = qb.baseBuilder.setupHeaders(httpRequest) - if err != nil { - return nil, err - } - err = qb.setupHeaders(httpRequest) - if err != nil { - return nil, err - } - - logger.Infof(nil, fmt.Sprintf( - "Built QingStor request: [%d] %s", - convert.StringToTimestamp(httpRequest.Header.Get("Date"), convert.RFC822), - httpRequest.URL.String(), - )) - - logger.Infof(nil, fmt.Sprintf( - "QingStor request headers: [%d] %s", - convert.StringToTimestamp(httpRequest.Header.Get("Date"), convert.RFC822), - fmt.Sprint(httpRequest.Header), - )) - - if qb.baseBuilder.parsedBodyString != "" { - logger.Infof(nil, fmt.Sprintf( - "QingStor request body string: [%d] %s", - convert.StringToTimestamp(httpRequest.Header.Get("Date"), convert.RFC822), - qb.baseBuilder.parsedBodyString, - )) - } - - return httpRequest, nil -} - -func (qb *QingStorBuilder) parseURL() error { - config := qb.baseBuilder.operation.Config - - zone := (*qb.baseBuilder.parsedProperties)["zone"] - port := strconv.Itoa(config.Port) - endpoint := config.Protocol + "://" + config.Host + ":" + port - if zone != "" { - endpoint = config.Protocol + "://" + zone + "." + config.Host + ":" + port - } - - requestURI := qb.baseBuilder.operation.RequestURI - for key, value := range *qb.baseBuilder.parsedProperties { - endpoint = strings.Replace(endpoint, "<"+key+">", utils.URLQueryEscape(value), -1) - requestURI = strings.Replace(requestURI, "<"+key+">", utils.URLQueryEscape(value), -1) - } - requestURI = regexp.MustCompile(`/+`).ReplaceAllString(requestURI, "/") - - requestURL, err := url.Parse(endpoint + requestURI) - if err != nil { - return err - } - - if qb.baseBuilder.parsedQuery != nil { - queryValue := requestURL.Query() - for key, value := range *qb.baseBuilder.parsedQuery { - queryValue.Set(key, value) - } - requestURL.RawQuery = queryValue.Encode() - } - - qb.baseBuilder.parsedURL = requestURL.String() - - return nil -} - -func (qb *QingStorBuilder) setupHeaders(httpRequest *http.Request) error { - if httpRequest.Header.Get("User-Agent") == "" { - version := fmt.Sprintf(`Go v%s`, strings.Replace(runtime.Version(), "go", "", -1)) - system := fmt.Sprintf(`%s_%s_%s`, runtime.GOOS, runtime.GOARCH, runtime.Compiler) - ua := fmt.Sprintf(`qingstor-sdk-go/%s (%s; %s)`, sdk.Version, version, system) - if qb.baseBuilder.operation.Config.AdditionalUserAgent != "" { - ua = fmt.Sprintf(`%s %s`, ua, qb.baseBuilder.operation.Config.AdditionalUserAgent) - } - httpRequest.Header.Set("User-Agent", ua) - } - - if s := httpRequest.Header.Get("X-QS-Fetch-Source"); s != "" { - u, err := url.Parse(s) - if err != nil { - return fmt.Errorf("invalid HTTP header value: %s", s) - } - httpRequest.Header.Set("X-QS-Fetch-Source", u.String()) - } - - if qb.baseBuilder.operation.APIName == "Delete Multiple Objects" { - buffer := &bytes.Buffer{} - buffer.ReadFrom(httpRequest.Body) - httpRequest.Body = ioutil.NopCloser(bytes.NewReader(buffer.Bytes())) - - md5Value := md5.Sum(buffer.Bytes()) - httpRequest.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5Value[:])) - } - - return nil -} diff --git a/vendor/github.com/yunify/qingstor-sdk-go/.gitignore b/vendor/github.com/yunify/qingstor-sdk-go/v3/.gitignore similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/.gitignore rename to vendor/github.com/yunify/qingstor-sdk-go/v3/.gitignore diff --git a/vendor/github.com/yunify/qingstor-sdk-go/.gitmodules b/vendor/github.com/yunify/qingstor-sdk-go/v3/.gitmodules similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/.gitmodules rename to vendor/github.com/yunify/qingstor-sdk-go/v3/.gitmodules diff --git a/vendor/github.com/yunify/qingstor-sdk-go/v3/.travis.yml b/vendor/github.com/yunify/qingstor-sdk-go/v3/.travis.yml new file mode 100644 index 000000000..67200c424 --- /dev/null +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/.travis.yml @@ -0,0 +1,39 @@ +sudo: required + +services: + - docker + +language: go +go: + - "1.12" + +env: + - GO111MODULE=on + +cache: + directories: + - ${HOME}/source + +before_install: + - pushd ${HOME}/source + - if [[ ! -d "./snips-v0.2.8" ]]; then + wget https://github.com/yunify/snips/releases/download/v0.2.8/snips-v0.2.8-linux_amd64.tar.gz && + mkdir snips-v0.2.8 && + pushd snips-v0.2.8 && + tar -vxzf ../snips-v0.2.8-linux_amd64.tar.gz && + popd; + fi + - pushd snips-v0.2.8 && sudo cp snips /usr/local/bin && popd + - popd + +install: + - go get -u golang.org/x/lint/golint; + - git submodule init + +before_script: + - make update + - make generate + +script: + - make check + - make build test test-coverage diff --git a/vendor/github.com/yunify/qingstor-sdk-go/AUTHORS b/vendor/github.com/yunify/qingstor-sdk-go/v3/AUTHORS similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/AUTHORS rename to vendor/github.com/yunify/qingstor-sdk-go/v3/AUTHORS diff --git a/vendor/github.com/yunify/qingstor-sdk-go/CHANGELOG.md b/vendor/github.com/yunify/qingstor-sdk-go/v3/CHANGELOG.md similarity index 80% rename from vendor/github.com/yunify/qingstor-sdk-go/CHANGELOG.md rename to vendor/github.com/yunify/qingstor-sdk-go/v3/CHANGELOG.md index 16b97fd84..6118aabff 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/CHANGELOG.md +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/CHANGELOG.md @@ -1,6 +1,39 @@ # Change Log All notable changes to QingStor SDK for Go will be documented in this file. +## [v3.0.2] - 2019-7-15 + +### Fixed + +- request/builder: Fix content length can't exceed int32 (#74) + +## [v3.0.1] - 2019-7-11 + +### Fixed + +- request/unpacker: Fix empty nginx error not parsed correctly (#72) + +## [v3.0.0] - 2019-6-26 + +### Changed + +- Use correct go module version +- From this release, go sdk will only provided by module, not zip anymore + +## [v2.3.0] - 2019-4-25 + +### Added + +- Add Content-Encoding header to put and post requests +- Add object cache control header +- Add `storage_class` in response element of API spec + +## [v2.2.15] - 2018-8-19 + +### Changed + +- Remove object content type detection + ## [v2.2.14] - 2018-6-9 ### Fixed @@ -162,6 +195,11 @@ All notable changes to QingStor SDK for Go will be documented in this file. - QingStor SDK for the Go programming language. +[v3.0.2]: https://github.com/yunify/qingstor-sdk-go/compare/v3.0.1...v3.0.2 +[v3.0.1]: https://github.com/yunify/qingstor-sdk-go/compare/v3.0.0...v3.0.1 +[v3.0.0]: https://github.com/yunify/qingstor-sdk-go/compare/v2.3.0...v3.0.0 +[v2.3.0]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.15...v2.3.0 +[v2.2.15]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.14...v2.2.15 [v2.2.14]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.13...v2.2.14 [v2.2.13]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.12...v2.2.13 [v2.2.12]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.11...v2.2.12 diff --git a/vendor/github.com/yunify/qingstor-sdk-go/LICENSE b/vendor/github.com/yunify/qingstor-sdk-go/v3/LICENSE similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/LICENSE rename to vendor/github.com/yunify/qingstor-sdk-go/v3/LICENSE diff --git a/vendor/github.com/yunify/qingstor-sdk-go/v3/MAINTAINERS b/vendor/github.com/yunify/qingstor-sdk-go/v3/MAINTAINERS new file mode 100644 index 000000000..1bb7b06d9 --- /dev/null +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/MAINTAINERS @@ -0,0 +1 @@ +Xuanwo diff --git a/vendor/github.com/yunify/qingstor-sdk-go/Makefile b/vendor/github.com/yunify/qingstor-sdk-go/v3/Makefile similarity index 77% rename from vendor/github.com/yunify/qingstor-sdk-go/Makefile rename to vendor/github.com/yunify/qingstor-sdk-go/v3/Makefile index e067b617a..e4b879257 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/Makefile +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/Makefile @@ -2,11 +2,9 @@ SHELL := /bin/bash PREFIX=qingstor-sdk-go VERSION=$(shell cat version.go | grep "Version\ =" | sed -e s/^.*\ //g | sed -e s/\"//g) -DIRS_TO_CHECK=$(shell ls -d */ | grep -vE "vendor|test") PKGS_TO_CHECK=$(shell go list ./... | grep -v "/vendor/") PKGS_TO_RELEASE=$(shell go list ./... | grep -vE "/vendor/|/test") FILES_TO_RELEASE=$(shell find . -name "*.go" | grep -vE "/vendor/|/test|.*_test.go") -FILES_TO_RELEASE_WITH_VENDOR=$(shell find . -name "*.go" | grep -vE "/test|.*_test.go") .PHONY: help help: @@ -20,8 +18,6 @@ help: @echo " test-coverage to run test with coverage" @echo " test-race to run test with race" @echo " integration-test to run integration test" - @echo " release to build and release current version" - @echo " release-source to pack the source code" @echo " clean to clean the coverage files" .PHONY: all @@ -39,7 +35,7 @@ format: .PHONY: vet vet: @echo "Go tool vet, skipping vendor packages" - @go tool vet -all ${DIRS_TO_CHECK} + @for pkg in ${PKGS_TO_RELEASE}; do go vet -all $${pkg}; done; @echo "Done" .PHONY: lint @@ -101,23 +97,6 @@ integration-test: pushd "./test"; go test; popd @echo "Done" -.PHONY: release -release: release-source release-source-with-vendor - -.PHONY: release-source -release-source: - @echo "Pack the source code" - mkdir -p "release" - zip -FS "release/${PREFIX}-source-v${VERSION}.zip" ${FILES_TO_RELEASE} - @echo "Done" - -.PHONY: release-source-with-vendor -release-source-with-vendor: - @echo "Pack the source code with vendor" - mkdir -p "release" - zip -FS "release/${PREFIX}-source-with-vendor-v${VERSION}.zip" ${FILES_TO_RELEASE_WITH_VENDOR} - @echo "Done" - .PHONY: clean clean: rm -rf $${PWD}/coverage diff --git a/vendor/github.com/yunify/qingstor-sdk-go/README.md b/vendor/github.com/yunify/qingstor-sdk-go/v3/README.md similarity index 96% rename from vendor/github.com/yunify/qingstor-sdk-go/README.md rename to vendor/github.com/yunify/qingstor-sdk-go/v3/README.md index 497ef9ba3..745c058e9 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/README.md +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/README.md @@ -41,8 +41,8 @@ package main import ( "fmt" - "github.com/yunify/qingstor-sdk-go/config" - qs "github.com/yunify/qingstor-sdk-go/service" + "github.com/yunify/qingstor-sdk-go/v3/config" + qs "github.com/yunify/qingstor-sdk-go/v3/service" ) func main() { diff --git a/vendor/github.com/yunify/qingstor-sdk-go/config/config.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/config/config.go similarity index 98% rename from vendor/github.com/yunify/qingstor-sdk-go/config/config.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/config/config.go index 9f355ade0..1d3346713 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/config/config.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/config/config.go @@ -26,8 +26,8 @@ import ( "gopkg.in/yaml.v2" - "github.com/yunify/qingstor-sdk-go/logger" - "github.com/yunify/qingstor-sdk-go/utils" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/utils" ) // A Config stores a configuration of this sdk. diff --git a/vendor/github.com/yunify/qingstor-sdk-go/config/contract.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/config/contract.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/config/contract.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/config/contract.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/v3/go.mod b/vendor/github.com/yunify/qingstor-sdk-go/v3/go.mod new file mode 100644 index 000000000..a01ef1003 --- /dev/null +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/go.mod @@ -0,0 +1,9 @@ +module github.com/yunify/qingstor-sdk-go/v3 + +go 1.12 + +require ( + github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14 + github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 + gopkg.in/yaml.v2 v2.2.2 +) diff --git a/vendor/github.com/yunify/qingstor-sdk-go/v3/go.sum b/vendor/github.com/yunify/qingstor-sdk-go/v3/go.sum new file mode 100644 index 000000000..9b38a503e --- /dev/null +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14 h1:XeOYlK9W1uCmhjJSsY78Mcuh7MVkNjTzmHx1yBzizSU= +github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14/go.mod h1:jVblp62SafmidSkvWrXyxAme3gaTfEtWwRPGz5cpvHg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 h1:Ko2LQMrRU+Oy/+EDBwX7eZ2jp3C47eDBB8EIhKTun+I= +github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/yunify/qingstor-sdk-go/logger/logger.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/logger/logger.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/logger/logger.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/logger/logger.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/builder/base.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/builder/builder.go similarity index 54% rename from vendor/github.com/yunify/qingstor-sdk-go/request/builder/base.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/builder/builder.go index 9871e17d6..f328a94ed 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/builder/base.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/builder/builder.go @@ -17,11 +17,19 @@ package builder import ( + "bytes" + "crypto/md5" + "encoding/base64" "encoding/json" "errors" + "fmt" "io" + "io/ioutil" "net/http" + "net/url" "reflect" + "regexp" + "runtime" "strconv" "strings" "time" @@ -29,12 +37,14 @@ import ( "github.com/pengsrc/go-shared/convert" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/utils" + "github.com/yunify/qingstor-sdk-go/v3" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/request/data" + "github.com/yunify/qingstor-sdk-go/v3/utils" ) -// BaseBuilder is the base builder for all services. -type BaseBuilder struct { +// Builder is the request builder for QingStor service. +type Builder struct { parsedURL string parsedProperties *map[string]string parsedQuery *map[string]string @@ -47,54 +57,148 @@ type BaseBuilder struct { } // BuildHTTPRequest builds http request with an operation and an input. -func (b *BaseBuilder) BuildHTTPRequest(o *data.Operation, i *reflect.Value) (*http.Request, error) { - b.operation = o - b.input = i +func (qb *Builder) BuildHTTPRequest(o *data.Operation, i *reflect.Value) (*http.Request, error) { + qb.operation = o + qb.input = i - _, err := b.parse() + err := qb.parse() if err != nil { return nil, err } - return b.build() -} - -func (b *BaseBuilder) build() (*http.Request, error) { - httpRequest, err := http.NewRequest(b.operation.RequestMethod, b.parsedURL, b.parsedBody) + httpRequest, err := http.NewRequest(qb.operation.RequestMethod, + qb.parsedURL, qb.parsedBody) if err != nil { return nil, err } - err = b.setupHeaders(httpRequest) + err = qb.setupHeaders(httpRequest) if err != nil { return nil, err } + timestamp := convert.StringToTimestamp(httpRequest.Header.Get("Date"), convert.RFC822) + + logger.Infof(nil, fmt.Sprintf( + "Built QingStor request: [%d] %s", + timestamp, + httpRequest.URL.String(), + )) + + logger.Infof(nil, fmt.Sprintf( + "QingStor request headers: [%d] %s", + timestamp, + fmt.Sprint(httpRequest.Header), + )) + + if qb.parsedBodyString != "" { + logger.Infof(nil, fmt.Sprintf( + "QingStor request body string: [%d] %s", + timestamp, + qb.parsedBodyString, + )) + } + return httpRequest, nil } -func (b *BaseBuilder) parse() (*BaseBuilder, error) { - err := b.parseRequestQueryAndHeaders() +func (qb *Builder) parse() error { + err := qb.parseRequestQueryAndHeaders() if err != nil { - return b, err + return err } - err = b.parseRequestBody() + err = qb.parseRequestBody() if err != nil { - return b, err + return err } - err = b.parseRequestProperties() + err = qb.parseRequestProperties() if err != nil { - return b, err + return err } - err = b.parseRequestURL() + err = qb.parseRequestURL() if err != nil { - return b, err + return err } - return b, nil + return nil } -func (b *BaseBuilder) parseRequestQueryAndHeaders() error { +func (qb *Builder) parseRequestBody() error { + requestData := map[string]interface{}{} + + if !qb.input.IsValid() { + return nil + } + + fields := qb.input.Elem() + if !fields.IsValid() { + return nil + } + + for i := 0; i < fields.NumField(); i++ { + location := fields.Type().Field(i).Tag.Get("location") + if location == "elements" { + name := fields.Type().Field(i).Tag.Get("name") + requestData[name] = fields.Field(i).Interface() + } + } + + if len(requestData) != 0 { + dataValue, err := json.Marshal(requestData) + if err != nil { + return err + } + + qb.parsedBodyString = string(dataValue) + qb.parsedBody = strings.NewReader(qb.parsedBodyString) + (*qb.parsedHeaders)["Content-Type"] = "application/json" + } else { + value := fields.FieldByName("Body") + if value.IsValid() { + switch value.Interface().(type) { + case string: + if value.String() != "" { + qb.parsedBodyString = value.String() + qb.parsedBody = strings.NewReader(value.String()) + } + case io.Reader: + if value.Interface().(io.Reader) != nil { + qb.parsedBody = value.Interface().(io.Reader) + } + } + } + } + + return nil +} + +func (qb *Builder) parseRequestProperties() error { + propertiesMap := map[string]string{} + qb.parsedProperties = &propertiesMap + + if qb.operation.Properties != nil { + fields := reflect.ValueOf(qb.operation.Properties).Elem() + if fields.IsValid() { + for i := 0; i < fields.NumField(); i++ { + switch value := fields.Field(i).Interface().(type) { + case *string: + if value != nil { + propertiesMap[fields.Type().Field(i).Tag.Get("name")] = *value + } + case *int: + if value != nil { + numberString := strconv.Itoa(int(*value)) + propertiesMap[fields.Type().Field(i).Tag.Get("name")] = numberString + } + } + } + } + } + + return nil +} + +func (qb *Builder) parseRequestQueryAndHeaders() error { requestQuery := map[string]string{} requestHeaders := map[string]string{} maps := map[string](map[string]string){ @@ -102,14 +206,14 @@ func (b *BaseBuilder) parseRequestQueryAndHeaders() error { "headers": requestHeaders, } - b.parsedQuery = &requestQuery - b.parsedHeaders = &requestHeaders + qb.parsedQuery = &requestQuery + qb.parsedHeaders = &requestHeaders - if !b.input.IsValid() { + if !qb.input.IsValid() { return nil } - fields := b.input.Elem() + fields := qb.input.Elem() if !fields.IsValid() { return nil } @@ -154,89 +258,44 @@ func (b *BaseBuilder) parseRequestQueryAndHeaders() error { return nil } -func (b *BaseBuilder) parseRequestBody() error { - requestData := map[string]interface{}{} +func (qb *Builder) parseRequestURL() error { + config := qb.operation.Config - if !b.input.IsValid() { - return nil + zone := (*qb.parsedProperties)["zone"] + port := strconv.Itoa(config.Port) + endpoint := config.Protocol + "://" + config.Host + ":" + port + if zone != "" { + endpoint = config.Protocol + "://" + zone + "." + config.Host + ":" + port } - fields := b.input.Elem() - if !fields.IsValid() { - return nil + requestURI := qb.operation.RequestURI + for key, value := range *qb.parsedProperties { + endpoint = strings.Replace(endpoint, "<"+key+">", utils.URLQueryEscape(value), -1) + requestURI = strings.Replace(requestURI, "<"+key+">", utils.URLQueryEscape(value), -1) + } + requestURI = regexp.MustCompile(`/+`).ReplaceAllString(requestURI, "/") + + requestURL, err := url.Parse(endpoint + requestURI) + if err != nil { + return err } - for i := 0; i < fields.NumField(); i++ { - location := fields.Type().Field(i).Tag.Get("location") - if location == "elements" { - name := fields.Type().Field(i).Tag.Get("name") - requestData[name] = fields.Field(i).Interface() - } - } - - if len(requestData) != 0 { - dataValue, err := json.Marshal(requestData) - if err != nil { - return err - } - - b.parsedBodyString = string(dataValue) - b.parsedBody = strings.NewReader(b.parsedBodyString) - (*b.parsedHeaders)["Content-Type"] = "application/json" - } else { - value := fields.FieldByName("Body") - if value.IsValid() { - switch value.Interface().(type) { - case string: - if value.String() != "" { - b.parsedBodyString = value.String() - b.parsedBody = strings.NewReader(value.String()) - } - case io.Reader: - if value.Interface().(io.Reader) != nil { - b.parsedBody = value.Interface().(io.Reader) - } - } + if qb.parsedQuery != nil { + queryValue := requestURL.Query() + for key, value := range *qb.parsedQuery { + queryValue.Set(key, value) } + requestURL.RawQuery = queryValue.Encode() } + qb.parsedURL = requestURL.String() return nil } -func (b *BaseBuilder) parseRequestProperties() error { - propertiesMap := map[string]string{} - b.parsedProperties = &propertiesMap +func (qb *Builder) setupHeaders(httpRequest *http.Request) error { + if qb.parsedHeaders != nil { - if b.operation.Properties != nil { - fields := reflect.ValueOf(b.operation.Properties).Elem() - if fields.IsValid() { - for i := 0; i < fields.NumField(); i++ { - switch value := fields.Field(i).Interface().(type) { - case *string: - if value != nil { - propertiesMap[fields.Type().Field(i).Tag.Get("name")] = *value - } - case *int: - if value != nil { - numberString := strconv.Itoa(int(*value)) - propertiesMap[fields.Type().Field(i).Tag.Get("name")] = numberString - } - } - } - } - } - - return nil -} - -func (b *BaseBuilder) parseRequestURL() error { - return nil -} - -func (b *BaseBuilder) setupHeaders(httpRequest *http.Request) error { - if b.parsedHeaders != nil { - - for headerKey, headerValue := range *b.parsedHeaders { + for headerKey, headerValue := range *qb.parsedHeaders { for _, r := range headerValue { if r > unicode.MaxASCII { headerValue = utils.URLQueryEscape(headerValue) @@ -250,7 +309,7 @@ func (b *BaseBuilder) setupHeaders(httpRequest *http.Request) error { if httpRequest.Header.Get("Content-Length") == "" { var length int64 - switch body := b.parsedBody.(type) { + switch body := qb.parsedBody.(type) { case nil: length = 0 case io.Seeker: @@ -277,7 +336,7 @@ func (b *BaseBuilder) setupHeaders(httpRequest *http.Request) error { httpRequest.Header.Set("Content-Length", "0") } } - length, err := strconv.Atoi(httpRequest.Header.Get("Content-Length")) + length, err := strconv.ParseInt(httpRequest.Header.Get("Content-Length"), 10, 64) if err != nil { return err } @@ -287,5 +346,32 @@ func (b *BaseBuilder) setupHeaders(httpRequest *http.Request) error { httpRequest.Header.Set("Date", convert.TimeToString(time.Now(), convert.RFC822)) } + if httpRequest.Header.Get("User-Agent") == "" { + version := fmt.Sprintf(`Go v%s`, strings.Replace(runtime.Version(), "go", "", -1)) + system := fmt.Sprintf(`%s_%s_%s`, runtime.GOOS, runtime.GOARCH, runtime.Compiler) + ua := fmt.Sprintf(`qingstor-sdk-go/%s (%s; %s)`, sdk.Version, version, system) + if qb.operation.Config.AdditionalUserAgent != "" { + ua = fmt.Sprintf(`%s %s`, ua, qb.operation.Config.AdditionalUserAgent) + } + httpRequest.Header.Set("User-Agent", ua) + } + + if s := httpRequest.Header.Get("X-QS-Fetch-Source"); s != "" { + u, err := url.Parse(s) + if err != nil { + return fmt.Errorf("invalid HTTP header value: %s", s) + } + httpRequest.Header.Set("X-QS-Fetch-Source", u.String()) + } + + if qb.operation.APIName == "Delete Multiple Objects" { + buffer := &bytes.Buffer{} + buffer.ReadFrom(httpRequest.Body) + httpRequest.Body = ioutil.NopCloser(bytes.NewReader(buffer.Bytes())) + + md5Value := md5.Sum(buffer.Bytes()) + httpRequest.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5Value[:])) + } + return nil } diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/data/input.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/input.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/request/data/input.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/input.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/data/operation.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/operation.go similarity index 96% rename from vendor/github.com/yunify/qingstor-sdk-go/request/data/operation.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/operation.go index 946fe869e..161fe40d7 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/data/operation.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/operation.go @@ -17,7 +17,7 @@ package data import ( - "github.com/yunify/qingstor-sdk-go/config" + "github.com/yunify/qingstor-sdk-go/v3/config" ) // Operation stores information of an operation. diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/data/validation.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/validation.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/request/data/validation.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/data/validation.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/errors/parameters.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/errors/parameters.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/request/errors/parameters.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/errors/parameters.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/errors/qingstor.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/errors/qingstor.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/request/errors/qingstor.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/errors/qingstor.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/request.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/request.go similarity index 94% rename from vendor/github.com/yunify/qingstor-sdk-go/request/request.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/request.go index afe202dbe..6fecc5c40 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/request.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/request.go @@ -26,11 +26,11 @@ import ( "github.com/pengsrc/go-shared/convert" - "github.com/yunify/qingstor-sdk-go/logger" - "github.com/yunify/qingstor-sdk-go/request/builder" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/request/signer" - "github.com/yunify/qingstor-sdk-go/request/unpacker" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/request/builder" + "github.com/yunify/qingstor-sdk-go/v3/request/data" + "github.com/yunify/qingstor-sdk-go/v3/request/signer" + "github.com/yunify/qingstor-sdk-go/v3/request/unpacker" ) // A Request can build, sign, send and unpack API request. @@ -168,7 +168,7 @@ func (r *Request) check() error { } func (r *Request) build() error { - b := &builder.QingStorBuilder{} + b := &builder.Builder{} httpRequest, err := b.BuildHTTPRequest(r.Operation, r.Input) if err != nil { return err diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/signer/qingstor.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/signer/qingstor.go similarity index 98% rename from vendor/github.com/yunify/qingstor-sdk-go/request/signer/qingstor.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/signer/qingstor.go index ab136845d..c26ce6319 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/signer/qingstor.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/signer/qingstor.go @@ -27,8 +27,8 @@ import ( "github.com/pengsrc/go-shared/convert" - "github.com/yunify/qingstor-sdk-go/logger" - "github.com/yunify/qingstor-sdk-go/utils" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/utils" ) // QingStorSigner is the http request signer for QingStor service. diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/base.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/base.go similarity index 98% rename from vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/base.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/base.go index 6ae057329..fa9ed0250 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/base.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/base.go @@ -27,8 +27,8 @@ import ( "github.com/pengsrc/go-shared/convert" - "github.com/yunify/qingstor-sdk-go/logger" - "github.com/yunify/qingstor-sdk-go/request/data" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/request/data" ) // BaseUnpacker is the base unpacker for all services. diff --git a/vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/qingstor.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/qingstor.go similarity index 56% rename from vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/qingstor.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/qingstor.go index 2ec6cb3db..80b6f7fb7 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/request/unpacker/qingstor.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/request/unpacker/qingstor.go @@ -19,11 +19,13 @@ package unpacker import ( "bytes" "encoding/json" + "io" "net/http" "reflect" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/request/errors" + "github.com/yunify/qingstor-sdk-go/v3/logger" + "github.com/yunify/qingstor-sdk-go/v3/request/data" + "github.com/yunify/qingstor-sdk-go/v3/request/errors" ) // QingStorUnpacker is the response unpacker for QingStor service. @@ -58,27 +60,43 @@ func (qu *QingStorUnpacker) UnpackHTTPRequest(o *data.Operation, r *http.Respons } func (qu *QingStorUnpacker) parseError() error { - if !qu.baseUnpacker.isResponseRight() { - if qu.baseUnpacker.httpResponse.Header.Get("Content-Type") == "application/json" { - buffer := &bytes.Buffer{} - buffer.ReadFrom(qu.baseUnpacker.httpResponse.Body) - qu.baseUnpacker.httpResponse.Body.Close() - - qsError := &errors.QingStorError{} - if buffer.Len() > 0 { - err := json.Unmarshal(buffer.Bytes(), qsError) - if err != nil { - return err - } - } - qsError.StatusCode = qu.baseUnpacker.httpResponse.StatusCode - if qsError.RequestID == "" { - qsError.RequestID = qu.baseUnpacker.httpResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID")) - } - - return qsError - } + if qu.baseUnpacker.isResponseRight() { + return nil } - return nil + // QingStor nginx could refuse user's request directly and only return status code. + // We should handle this and build a qingstor error with message. + if qu.baseUnpacker.httpResponse.Header.Get("Content-Type") != "application/json" { + qsError := &errors.QingStorError{ + StatusCode: qu.baseUnpacker.httpResponse.StatusCode, + Message: http.StatusText(qu.baseUnpacker.httpResponse.StatusCode), + } + return qsError + } + + buffer := &bytes.Buffer{} + _, err := io.Copy(buffer, qu.baseUnpacker.httpResponse.Body) + if err != nil { + logger.Errorf(nil, "Copy from error response body failed for %v", err) + return err + } + err = qu.baseUnpacker.httpResponse.Body.Close() + if err != nil { + logger.Errorf(nil, "Close error response body failed for %v", err) + return err + } + + qsError := &errors.QingStorError{} + if buffer.Len() > 0 { + err := json.Unmarshal(buffer.Bytes(), qsError) + if err != nil { + return err + } + } + qsError.StatusCode = qu.baseUnpacker.httpResponse.StatusCode + if qsError.RequestID == "" { + qsError.RequestID = qu.baseUnpacker.httpResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID")) + } + + return qsError } diff --git a/vendor/github.com/yunify/qingstor-sdk-go/service/bucket.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/bucket.go similarity index 99% rename from vendor/github.com/yunify/qingstor-sdk-go/service/bucket.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/service/bucket.go index 69dd914ba..9abc25368 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/service/bucket.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/bucket.go @@ -23,10 +23,10 @@ import ( "strings" "time" - "github.com/yunify/qingstor-sdk-go/config" - "github.com/yunify/qingstor-sdk-go/request" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/request/errors" + "github.com/yunify/qingstor-sdk-go/v3/config" + "github.com/yunify/qingstor-sdk-go/v3/request" + "github.com/yunify/qingstor-sdk-go/v3/request/data" + "github.com/yunify/qingstor-sdk-go/v3/request/errors" ) var _ fmt.State @@ -1080,6 +1080,8 @@ type ListObjectsOutput struct { CommonPrefixes []*string `json:"common_prefixes,omitempty" name:"common_prefixes" location:"elements"` // Delimiter that specified in request parameters Delimiter *string `json:"delimiter,omitempty" name:"delimiter" location:"elements"` + // Indicate if these are more results in the next page + HasMore *bool `json:"has_more,omitempty" name:"has_more" location:"elements"` // Object keys Keys []*KeyType `json:"keys,omitempty" name:"keys" location:"elements"` // Limit that specified in request parameters diff --git a/vendor/github.com/yunify/qingstor-sdk-go/service/convert_types.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/convert_types.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/service/convert_types.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/service/convert_types.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/service/object.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/object.go similarity index 98% rename from vendor/github.com/yunify/qingstor-sdk-go/service/object.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/service/object.go index e2d080aa2..02177691e 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/service/object.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/object.go @@ -23,10 +23,10 @@ import ( "strings" "time" - "github.com/yunify/qingstor-sdk-go/config" - "github.com/yunify/qingstor-sdk-go/request" - "github.com/yunify/qingstor-sdk-go/request/data" - "github.com/yunify/qingstor-sdk-go/request/errors" + "github.com/yunify/qingstor-sdk-go/v3/config" + "github.com/yunify/qingstor-sdk-go/v3/request" + "github.com/yunify/qingstor-sdk-go/v3/request/data" + "github.com/yunify/qingstor-sdk-go/v3/request/errors" ) var _ fmt.State @@ -963,6 +963,10 @@ func (s *Bucket) PutObjectRequest(objectKey string, input *PutObjectInput) (*req // PutObjectInput presents input for PutObject. type PutObjectInput struct { + // Object cache control + CacheControl *string `json:"Cache-Control,omitempty" name:"Cache-Control" location:"headers"` + // Object content encoding + ContentEncoding *string `json:"Content-Encoding,omitempty" name:"Content-Encoding" location:"headers"` // Object content size ContentLength *int64 `json:"Content-Length" name:"Content-Length" location:"headers"` // Required // Object MD5sum diff --git a/vendor/github.com/yunify/qingstor-sdk-go/service/qingstor.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/qingstor.go similarity index 95% rename from vendor/github.com/yunify/qingstor-sdk-go/service/qingstor.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/service/qingstor.go index c2ebe25c8..dbfd0ae0b 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/service/qingstor.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/qingstor.go @@ -20,9 +20,9 @@ package service import ( "net/http" - "github.com/yunify/qingstor-sdk-go/config" - "github.com/yunify/qingstor-sdk-go/request" - "github.com/yunify/qingstor-sdk-go/request/data" + "github.com/yunify/qingstor-sdk-go/v3/config" + "github.com/yunify/qingstor-sdk-go/v3/request" + "github.com/yunify/qingstor-sdk-go/v3/request/data" ) var _ http.Header diff --git a/vendor/github.com/yunify/qingstor-sdk-go/service/types.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/types.go similarity index 99% rename from vendor/github.com/yunify/qingstor-sdk-go/service/types.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/service/types.go index efe907e21..fec50b7af 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/service/types.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/service/types.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "github.com/yunify/qingstor-sdk-go/request/errors" + "github.com/yunify/qingstor-sdk-go/v3/request/errors" ) // Properties presents the service properties. @@ -343,6 +343,8 @@ type KeyType struct { Modified *int `json:"modified,omitempty" name:"modified"` // Object content size Size *int64 `json:"size,omitempty" name:"size"` + // Object storage class + StorageClass *string `json:"storage_class,omitempty" name:"storage_class"` } // Validate validates the Key. diff --git a/vendor/github.com/yunify/qingstor-sdk-go/utils/conn.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/utils/conn.go similarity index 96% rename from vendor/github.com/yunify/qingstor-sdk-go/utils/conn.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/utils/conn.go index 9f5a5587a..cbbf8f7ae 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/utils/conn.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/utils/conn.go @@ -3,12 +3,9 @@ package utils import ( "context" "net" - "sync" "time" ) -var connPool sync.Pool - type netConn net.Conn type netDialer net.Dialer @@ -71,10 +68,7 @@ func NewConn(c netConn) *Conn { if ok { return conn } - conn, ok = connPool.Get().(*Conn) - if !ok { - conn = new(Conn) - } + conn = new(Conn) conn.netConn = c return conn } @@ -119,7 +113,6 @@ func (c Conn) Close() (err error) { return nil } err = c.netConn.Close() - connPool.Put(c) c.netConn = nil c.readTimeout = 0 c.writeTimeout = 0 diff --git a/vendor/github.com/yunify/qingstor-sdk-go/utils/escape.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/utils/escape.go similarity index 100% rename from vendor/github.com/yunify/qingstor-sdk-go/utils/escape.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/utils/escape.go diff --git a/vendor/github.com/yunify/qingstor-sdk-go/version.go b/vendor/github.com/yunify/qingstor-sdk-go/v3/version.go similarity index 97% rename from vendor/github.com/yunify/qingstor-sdk-go/version.go rename to vendor/github.com/yunify/qingstor-sdk-go/v3/version.go index 0663775ce..15ed27bb2 100644 --- a/vendor/github.com/yunify/qingstor-sdk-go/version.go +++ b/vendor/github.com/yunify/qingstor-sdk-go/v3/version.go @@ -20,4 +20,4 @@ package sdk // Version number. -const Version = "2.2.15" +const Version = "3.0.2" diff --git a/vendor/modules.txt b/vendor/modules.txt index 84810a21f..5b860c7f8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -131,7 +131,7 @@ github.com/nsf/termbox-go github.com/okzk/sdnotify # github.com/patrickmn/go-cache v2.1.0+incompatible github.com/patrickmn/go-cache -# github.com/pengsrc/go-shared v0.2.0 +# github.com/pengsrc/go-shared v0.2.1-0.20190131101655-1999055a4a14 github.com/pengsrc/go-shared/log github.com/pengsrc/go-shared/convert github.com/pengsrc/go-shared/buffer @@ -158,25 +158,25 @@ github.com/spf13/cobra github.com/spf13/cobra/doc # github.com/spf13/pflag v1.0.3 github.com/spf13/pflag -# github.com/stretchr/testify v1.3.0 +# github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 github.com/stretchr/testify/assert github.com/stretchr/testify/require # github.com/t3rm1n4l/go-mega v0.0.0-20190528125457-55e675378686 github.com/t3rm1n4l/go-mega # github.com/xanzy/ssh-agent v0.2.1 github.com/xanzy/ssh-agent -# github.com/yunify/qingstor-sdk-go v2.2.15+incompatible -github.com/yunify/qingstor-sdk-go/config -github.com/yunify/qingstor-sdk-go/request/errors -github.com/yunify/qingstor-sdk-go/service -github.com/yunify/qingstor-sdk-go/logger -github.com/yunify/qingstor-sdk-go/utils -github.com/yunify/qingstor-sdk-go/request -github.com/yunify/qingstor-sdk-go/request/data -github.com/yunify/qingstor-sdk-go/request/builder -github.com/yunify/qingstor-sdk-go/request/signer -github.com/yunify/qingstor-sdk-go/request/unpacker -github.com/yunify/qingstor-sdk-go +# github.com/yunify/qingstor-sdk-go/v3 v3.0.2 +github.com/yunify/qingstor-sdk-go/v3/config +github.com/yunify/qingstor-sdk-go/v3/request/errors +github.com/yunify/qingstor-sdk-go/v3/service +github.com/yunify/qingstor-sdk-go/v3/logger +github.com/yunify/qingstor-sdk-go/v3/utils +github.com/yunify/qingstor-sdk-go/v3/request +github.com/yunify/qingstor-sdk-go/v3/request/data +github.com/yunify/qingstor-sdk-go/v3/request/builder +github.com/yunify/qingstor-sdk-go/v3/request/signer +github.com/yunify/qingstor-sdk-go/v3/request/unpacker +github.com/yunify/qingstor-sdk-go/v3 # go.opencensus.io v0.22.0 go.opencensus.io/plugin/ochttp go.opencensus.io/plugin/ochttp/propagation/b3