remove unused vendor packages (#1620)
This commit is contained in:
parent
e4a0a04829
commit
e3c2963222
24
vendor/github.com/gopherjs/gopherjs/LICENSE
generated
vendored
24
vendor/github.com/gopherjs/gopherjs/LICENSE
generated
vendored
|
@ -1,24 +0,0 @@
|
||||||
Copyright (c) 2013 Richard Musiol. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
168
vendor/github.com/gopherjs/gopherjs/js/js.go
generated
vendored
168
vendor/github.com/gopherjs/gopherjs/js/js.go
generated
vendored
|
@ -1,168 +0,0 @@
|
||||||
// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax.
|
|
||||||
//
|
|
||||||
// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed:
|
|
||||||
//
|
|
||||||
// | Go type | JavaScript type | Conversions back to interface{} |
|
|
||||||
// | --------------------- | --------------------- | ------------------------------- |
|
|
||||||
// | bool | Boolean | bool |
|
|
||||||
// | integers and floats | Number | float64 |
|
|
||||||
// | string | String | string |
|
|
||||||
// | []int8 | Int8Array | []int8 |
|
|
||||||
// | []int16 | Int16Array | []int16 |
|
|
||||||
// | []int32, []int | Int32Array | []int |
|
|
||||||
// | []uint8 | Uint8Array | []uint8 |
|
|
||||||
// | []uint16 | Uint16Array | []uint16 |
|
|
||||||
// | []uint32, []uint | Uint32Array | []uint |
|
|
||||||
// | []float32 | Float32Array | []float32 |
|
|
||||||
// | []float64 | Float64Array | []float64 |
|
|
||||||
// | all other slices | Array | []interface{} |
|
|
||||||
// | arrays | see slice type | see slice type |
|
|
||||||
// | functions | Function | func(...interface{}) *js.Object |
|
|
||||||
// | time.Time | Date | time.Time |
|
|
||||||
// | - | instanceof Node | *js.Object |
|
|
||||||
// | maps, structs | instanceof Object | map[string]interface{} |
|
|
||||||
//
|
|
||||||
// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa.
|
|
||||||
package js
|
|
||||||
|
|
||||||
// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key.
|
|
||||||
type Object struct{ object *Object }
|
|
||||||
|
|
||||||
// Get returns the object's property with the given key.
|
|
||||||
func (o *Object) Get(key string) *Object { return o.object.Get(key) }
|
|
||||||
|
|
||||||
// Set assigns the value to the object's property with the given key.
|
|
||||||
func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) }
|
|
||||||
|
|
||||||
// Delete removes the object's property with the given key.
|
|
||||||
func (o *Object) Delete(key string) { o.object.Delete(key) }
|
|
||||||
|
|
||||||
// Length returns the object's "length" property, converted to int.
|
|
||||||
func (o *Object) Length() int { return o.object.Length() }
|
|
||||||
|
|
||||||
// Index returns the i'th element of an array.
|
|
||||||
func (o *Object) Index(i int) *Object { return o.object.Index(i) }
|
|
||||||
|
|
||||||
// SetIndex sets the i'th element of an array.
|
|
||||||
func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) }
|
|
||||||
|
|
||||||
// Call calls the object's method with the given name.
|
|
||||||
func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) }
|
|
||||||
|
|
||||||
// Invoke calls the object itself. This will fail if it is not a function.
|
|
||||||
func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) }
|
|
||||||
|
|
||||||
// New creates a new instance of this type object. This will fail if it not a function (constructor).
|
|
||||||
func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) }
|
|
||||||
|
|
||||||
// Bool returns the object converted to bool according to JavaScript type conversions.
|
|
||||||
func (o *Object) Bool() bool { return o.object.Bool() }
|
|
||||||
|
|
||||||
// String returns the object converted to string according to JavaScript type conversions.
|
|
||||||
func (o *Object) String() string { return o.object.String() }
|
|
||||||
|
|
||||||
// Int returns the object converted to int according to JavaScript type conversions (parseInt).
|
|
||||||
func (o *Object) Int() int { return o.object.Int() }
|
|
||||||
|
|
||||||
// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt).
|
|
||||||
func (o *Object) Int64() int64 { return o.object.Int64() }
|
|
||||||
|
|
||||||
// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt).
|
|
||||||
func (o *Object) Uint64() uint64 { return o.object.Uint64() }
|
|
||||||
|
|
||||||
// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat).
|
|
||||||
func (o *Object) Float() float64 { return o.object.Float() }
|
|
||||||
|
|
||||||
// Interface returns the object converted to interface{}. See GopherJS' README for details.
|
|
||||||
func (o *Object) Interface() interface{} { return o.object.Interface() }
|
|
||||||
|
|
||||||
// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use.
|
|
||||||
func (o *Object) Unsafe() uintptr { return o.object.Unsafe() }
|
|
||||||
|
|
||||||
// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object.
|
|
||||||
type Error struct {
|
|
||||||
*Object
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error returns the message of the encapsulated JavaScript error object.
|
|
||||||
func (err *Error) Error() string {
|
|
||||||
return "JavaScript error: " + err.Get("message").String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stack returns the stack property of the encapsulated JavaScript error object.
|
|
||||||
func (err *Error) Stack() string {
|
|
||||||
return err.Get("stack").String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js).
|
|
||||||
var Global *Object
|
|
||||||
|
|
||||||
// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'.
|
|
||||||
var Module *Object
|
|
||||||
|
|
||||||
// Undefined gives the JavaScript value "undefined".
|
|
||||||
var Undefined *Object
|
|
||||||
|
|
||||||
// Debugger gets compiled to JavaScript's "debugger;" statement.
|
|
||||||
func Debugger() {}
|
|
||||||
|
|
||||||
// InternalObject returns the internal JavaScript object that represents i. Not intended for public use.
|
|
||||||
func InternalObject(i interface{}) *Object {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords.
|
|
||||||
func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object {
|
|
||||||
return Global.Call("$makeFunc", InternalObject(fn))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keys returns the keys of the given JavaScript object.
|
|
||||||
func Keys(o *Object) []string {
|
|
||||||
if o == nil || o == Undefined {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
a := Global.Get("Object").Call("keys", o)
|
|
||||||
s := make([]string, a.Length())
|
|
||||||
for i := 0; i < a.Length(); i++ {
|
|
||||||
s[i] = a.Index(i).String()
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript.
|
|
||||||
func MakeWrapper(i interface{}) *Object {
|
|
||||||
v := InternalObject(i)
|
|
||||||
o := Global.Get("Object").New()
|
|
||||||
o.Set("__internal_object__", v)
|
|
||||||
methods := v.Get("constructor").Get("methods")
|
|
||||||
for i := 0; i < methods.Length(); i++ {
|
|
||||||
m := methods.Index(i)
|
|
||||||
if m.Get("pkg").String() != "" { // not exported
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
o.Set(m.Get("name").String(), func(args ...*Object) *Object {
|
|
||||||
return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice.
|
|
||||||
func NewArrayBuffer(b []byte) *Object {
|
|
||||||
slice := InternalObject(b)
|
|
||||||
offset := slice.Get("$offset").Int()
|
|
||||||
length := slice.Get("$length").Int()
|
|
||||||
return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length)
|
|
||||||
}
|
|
||||||
|
|
||||||
// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion).
|
|
||||||
type M map[string]interface{}
|
|
||||||
|
|
||||||
// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion).
|
|
||||||
type S []interface{}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
// avoid dead code elimination
|
|
||||||
e := Error{}
|
|
||||||
_ = e
|
|
||||||
}
|
|
18
vendor/github.com/jtolds/gls/LICENSE
generated
vendored
18
vendor/github.com/jtolds/gls/LICENSE
generated
vendored
|
@ -1,18 +0,0 @@
|
||||||
Copyright (c) 2013, Space Monkey, Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
89
vendor/github.com/jtolds/gls/README.md
generated
vendored
89
vendor/github.com/jtolds/gls/README.md
generated
vendored
|
@ -1,89 +0,0 @@
|
||||||
gls
|
|
||||||
===
|
|
||||||
|
|
||||||
Goroutine local storage
|
|
||||||
|
|
||||||
### IMPORTANT NOTE ###
|
|
||||||
|
|
||||||
It is my duty to point you to https://blog.golang.org/context, which is how
|
|
||||||
Google solves all of the problems you'd perhaps consider using this package
|
|
||||||
for at scale.
|
|
||||||
|
|
||||||
One downside to Google's approach is that *all* of your functions must have
|
|
||||||
a new first argument, but after clearing that hurdle everything else is much
|
|
||||||
better.
|
|
||||||
|
|
||||||
If you aren't interested in this warning, read on.
|
|
||||||
|
|
||||||
### Huhwaht? Why? ###
|
|
||||||
|
|
||||||
Every so often, a thread shows up on the
|
|
||||||
[golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some
|
|
||||||
form of goroutine-local-storage, or some kind of goroutine id, or some kind of
|
|
||||||
context. There are a few valid use cases for goroutine-local-storage, one of
|
|
||||||
the most prominent being log line context. One poster was interested in being
|
|
||||||
able to log an HTTP request context id in every log line in the same goroutine
|
|
||||||
as the incoming HTTP request, without having to change every library and
|
|
||||||
function call he was interested in logging.
|
|
||||||
|
|
||||||
This would be pretty useful. Provided that you could get some kind of
|
|
||||||
goroutine-local-storage, you could call
|
|
||||||
[log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging
|
|
||||||
writer that checks goroutine-local-storage for some context information and
|
|
||||||
adds that context to your log lines.
|
|
||||||
|
|
||||||
But alas, Andrew Gerrand's typically diplomatic answer to the question of
|
|
||||||
goroutine-local variables was:
|
|
||||||
|
|
||||||
> We wouldn't even be having this discussion if thread local storage wasn't
|
|
||||||
> useful. But every feature comes at a cost, and in my opinion the cost of
|
|
||||||
> threadlocals far outweighs their benefits. They're just not a good fit for
|
|
||||||
> Go.
|
|
||||||
|
|
||||||
So, yeah, that makes sense. That's a pretty good reason for why the language
|
|
||||||
won't support a specific and (relatively) unuseful feature that requires some
|
|
||||||
runtime changes, just for the sake of a little bit of log improvement.
|
|
||||||
|
|
||||||
But does Go require runtime changes?
|
|
||||||
|
|
||||||
### How it works ###
|
|
||||||
|
|
||||||
Go has pretty fantastic introspective and reflective features, but one thing Go
|
|
||||||
doesn't give you is any kind of access to the stack pointer, or frame pointer,
|
|
||||||
or goroutine id, or anything contextual about your current stack. It gives you
|
|
||||||
access to your list of callers, but only along with program counters, which are
|
|
||||||
fixed at compile time.
|
|
||||||
|
|
||||||
But it does give you the stack.
|
|
||||||
|
|
||||||
So, we define 16 special functions and embed base-16 tags into the stack using
|
|
||||||
the call order of those 16 functions. Then, we can read our tags back out of
|
|
||||||
the stack looking at the callers list.
|
|
||||||
|
|
||||||
We then use these tags as an index into a traditional map for implementing
|
|
||||||
this library.
|
|
||||||
|
|
||||||
### What are people saying? ###
|
|
||||||
|
|
||||||
"Wow, that's horrifying."
|
|
||||||
|
|
||||||
"This is the most terrible thing I have seen in a very long time."
|
|
||||||
|
|
||||||
"Where is it getting a context from? Is this serializing all the requests?
|
|
||||||
What the heck is the client being bound to? What are these tags? Why does he
|
|
||||||
need callers? Oh god no. No no no."
|
|
||||||
|
|
||||||
### Docs ###
|
|
||||||
|
|
||||||
Please see the docs at http://godoc.org/github.com/jtolds/gls
|
|
||||||
|
|
||||||
### Related ###
|
|
||||||
|
|
||||||
If you're okay relying on the string format of the current runtime stacktrace
|
|
||||||
including a unique goroutine id (not guaranteed by the spec or anything, but
|
|
||||||
very unlikely to change within a Go release), you might be able to squeeze
|
|
||||||
out a bit more performance by using this similar library, inspired by some
|
|
||||||
code Brad Fitzpatrick wrote for debugging his HTTP/2 library:
|
|
||||||
https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require
|
|
||||||
any knowledge of the string format of the runtime stacktrace, which
|
|
||||||
probably adds unnecessary overhead).
|
|
144
vendor/github.com/jtolds/gls/context.go
generated
vendored
144
vendor/github.com/jtolds/gls/context.go
generated
vendored
|
@ -1,144 +0,0 @@
|
||||||
// Package gls implements goroutine-local storage.
|
|
||||||
package gls
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
maxCallers = 64
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
stackTagPool = &idPool{}
|
|
||||||
mgrRegistry = make(map[*ContextManager]bool)
|
|
||||||
mgrRegistryMtx sync.RWMutex
|
|
||||||
)
|
|
||||||
|
|
||||||
// Values is simply a map of key types to value types. Used by SetValues to
|
|
||||||
// set multiple values at once.
|
|
||||||
type Values map[interface{}]interface{}
|
|
||||||
|
|
||||||
// ContextManager is the main entrypoint for interacting with
|
|
||||||
// Goroutine-local-storage. You can have multiple independent ContextManagers
|
|
||||||
// at any given time. ContextManagers are usually declared globally for a given
|
|
||||||
// class of context variables. You should use NewContextManager for
|
|
||||||
// construction.
|
|
||||||
type ContextManager struct {
|
|
||||||
mtx sync.RWMutex
|
|
||||||
values map[uint]Values
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewContextManager returns a brand new ContextManager. It also registers the
|
|
||||||
// new ContextManager in the ContextManager registry which is used by the Go
|
|
||||||
// method. ContextManagers are typically defined globally at package scope.
|
|
||||||
func NewContextManager() *ContextManager {
|
|
||||||
mgr := &ContextManager{values: make(map[uint]Values)}
|
|
||||||
mgrRegistryMtx.Lock()
|
|
||||||
defer mgrRegistryMtx.Unlock()
|
|
||||||
mgrRegistry[mgr] = true
|
|
||||||
return mgr
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unregister removes a ContextManager from the global registry, used by the
|
|
||||||
// Go method. Only intended for use when you're completely done with a
|
|
||||||
// ContextManager. Use of Unregister at all is rare.
|
|
||||||
func (m *ContextManager) Unregister() {
|
|
||||||
mgrRegistryMtx.Lock()
|
|
||||||
defer mgrRegistryMtx.Unlock()
|
|
||||||
delete(mgrRegistry, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetValues takes a collection of values and a function to call for those
|
|
||||||
// values to be set in. Anything further down the stack will have the set
|
|
||||||
// values available through GetValue. SetValues will add new values or replace
|
|
||||||
// existing values of the same key and will not mutate or change values for
|
|
||||||
// previous stack frames.
|
|
||||||
// SetValues is slow (makes a copy of all current and new values for the new
|
|
||||||
// gls-context) in order to reduce the amount of lookups GetValue requires.
|
|
||||||
func (m *ContextManager) SetValues(new_values Values, context_call func()) {
|
|
||||||
if len(new_values) == 0 {
|
|
||||||
context_call()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tags := readStackTags(1)
|
|
||||||
|
|
||||||
m.mtx.Lock()
|
|
||||||
values := new_values
|
|
||||||
for _, tag := range tags {
|
|
||||||
if existing_values, ok := m.values[tag]; ok {
|
|
||||||
// oh, we found existing values, let's make a copy
|
|
||||||
values = make(Values, len(existing_values)+len(new_values))
|
|
||||||
for key, val := range existing_values {
|
|
||||||
values[key] = val
|
|
||||||
}
|
|
||||||
for key, val := range new_values {
|
|
||||||
values[key] = val
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new_tag := stackTagPool.Acquire()
|
|
||||||
m.values[new_tag] = values
|
|
||||||
m.mtx.Unlock()
|
|
||||||
defer func() {
|
|
||||||
m.mtx.Lock()
|
|
||||||
delete(m.values, new_tag)
|
|
||||||
m.mtx.Unlock()
|
|
||||||
stackTagPool.Release(new_tag)
|
|
||||||
}()
|
|
||||||
|
|
||||||
addStackTag(new_tag, context_call)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetValue will return a previously set value, provided that the value was set
|
|
||||||
// by SetValues somewhere higher up the stack. If the value is not found, ok
|
|
||||||
// will be false.
|
|
||||||
func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) {
|
|
||||||
|
|
||||||
tags := readStackTags(1)
|
|
||||||
m.mtx.RLock()
|
|
||||||
defer m.mtx.RUnlock()
|
|
||||||
for _, tag := range tags {
|
|
||||||
if values, ok := m.values[tag]; ok {
|
|
||||||
value, ok := values[key]
|
|
||||||
return value, ok
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ContextManager) getValues() Values {
|
|
||||||
tags := readStackTags(2)
|
|
||||||
m.mtx.RLock()
|
|
||||||
defer m.mtx.RUnlock()
|
|
||||||
for _, tag := range tags {
|
|
||||||
if values, ok := m.values[tag]; ok {
|
|
||||||
return values
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go preserves ContextManager values and Goroutine-local-storage across new
|
|
||||||
// goroutine invocations. The Go method makes a copy of all existing values on
|
|
||||||
// all registered context managers and makes sure they are still set after
|
|
||||||
// kicking off the provided function in a new goroutine. If you don't use this
|
|
||||||
// Go method instead of the standard 'go' keyword, you will lose values in
|
|
||||||
// ContextManagers, as goroutines have brand new stacks.
|
|
||||||
func Go(cb func()) {
|
|
||||||
mgrRegistryMtx.RLock()
|
|
||||||
defer mgrRegistryMtx.RUnlock()
|
|
||||||
|
|
||||||
for mgr, _ := range mgrRegistry {
|
|
||||||
values := mgr.getValues()
|
|
||||||
if len(values) > 0 {
|
|
||||||
mgr_copy := mgr
|
|
||||||
cb_copy := cb
|
|
||||||
cb = func() { mgr_copy.SetValues(values, cb_copy) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
go cb()
|
|
||||||
}
|
|
13
vendor/github.com/jtolds/gls/gen_sym.go
generated
vendored
13
vendor/github.com/jtolds/gls/gen_sym.go
generated
vendored
|
@ -1,13 +0,0 @@
|
||||||
package gls
|
|
||||||
|
|
||||||
var (
|
|
||||||
symPool = &idPool{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// ContextKey is a throwaway value you can use as a key to a ContextManager
|
|
||||||
type ContextKey struct{ id uint }
|
|
||||||
|
|
||||||
// GenSym will return a brand new, never-before-used ContextKey
|
|
||||||
func GenSym() ContextKey {
|
|
||||||
return ContextKey{id: symPool.Acquire()}
|
|
||||||
}
|
|
34
vendor/github.com/jtolds/gls/id_pool.go
generated
vendored
34
vendor/github.com/jtolds/gls/id_pool.go
generated
vendored
|
@ -1,34 +0,0 @@
|
||||||
package gls
|
|
||||||
|
|
||||||
// though this could probably be better at keeping ids smaller, the goal of
|
|
||||||
// this class is to keep a registry of the smallest unique integer ids
|
|
||||||
// per-process possible
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
type idPool struct {
|
|
||||||
mtx sync.Mutex
|
|
||||||
released []uint
|
|
||||||
max_id uint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *idPool) Acquire() (id uint) {
|
|
||||||
p.mtx.Lock()
|
|
||||||
defer p.mtx.Unlock()
|
|
||||||
if len(p.released) > 0 {
|
|
||||||
id = p.released[len(p.released)-1]
|
|
||||||
p.released = p.released[:len(p.released)-1]
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
id = p.max_id
|
|
||||||
p.max_id++
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *idPool) Release(id uint) {
|
|
||||||
p.mtx.Lock()
|
|
||||||
defer p.mtx.Unlock()
|
|
||||||
p.released = append(p.released, id)
|
|
||||||
}
|
|
43
vendor/github.com/jtolds/gls/stack_tags.go
generated
vendored
43
vendor/github.com/jtolds/gls/stack_tags.go
generated
vendored
|
@ -1,43 +0,0 @@
|
||||||
package gls
|
|
||||||
|
|
||||||
// so, basically, we're going to encode integer tags in base-16 on the stack
|
|
||||||
|
|
||||||
const (
|
|
||||||
bitWidth = 4
|
|
||||||
)
|
|
||||||
|
|
||||||
func addStackTag(tag uint, context_call func()) {
|
|
||||||
if context_call == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
markS(tag, context_call)
|
|
||||||
}
|
|
||||||
|
|
||||||
func markS(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark0(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark1(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark2(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark3(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark4(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark5(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark6(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark7(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark8(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func mark9(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markA(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markB(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markC(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markD(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markE(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
func markF(tag uint, cb func()) { _m(tag, cb) }
|
|
||||||
|
|
||||||
var pc_lookup = make(map[uintptr]int8, 17)
|
|
||||||
var mark_lookup [16]func(uint, func())
|
|
||||||
|
|
||||||
func _m(tag_remainder uint, cb func()) {
|
|
||||||
if tag_remainder == 0 {
|
|
||||||
cb()
|
|
||||||
} else {
|
|
||||||
mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb)
|
|
||||||
}
|
|
||||||
}
|
|
101
vendor/github.com/jtolds/gls/stack_tags_js.go
generated
vendored
101
vendor/github.com/jtolds/gls/stack_tags_js.go
generated
vendored
|
@ -1,101 +0,0 @@
|
||||||
// +build js
|
|
||||||
|
|
||||||
package gls
|
|
||||||
|
|
||||||
// This file is used for GopherJS builds, which don't have normal runtime support
|
|
||||||
|
|
||||||
import (
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gopherjs/gopherjs/js"
|
|
||||||
)
|
|
||||||
|
|
||||||
var stackRE = regexp.MustCompile("\\s+at (\\S*) \\([^:]+:(\\d+):(\\d+)")
|
|
||||||
|
|
||||||
func findPtr() uintptr {
|
|
||||||
jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n")
|
|
||||||
for i := 1; i < jsStack.Get("length").Int(); i++ {
|
|
||||||
item := jsStack.Index(i).String()
|
|
||||||
matches := stackRE.FindAllStringSubmatch(item, -1)
|
|
||||||
if matches == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
pkgPath := matches[0][1]
|
|
||||||
if strings.HasPrefix(pkgPath, "$packages.github.com/jtolds/gls.mark") {
|
|
||||||
line, _ := strconv.Atoi(matches[0][2])
|
|
||||||
char, _ := strconv.Atoi(matches[0][3])
|
|
||||||
x := (uintptr(line) << 16) | uintptr(char)
|
|
||||||
return x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
setEntries := func(f func(uint, func()), v int8) {
|
|
||||||
var ptr uintptr
|
|
||||||
f(0, func() {
|
|
||||||
ptr = findPtr()
|
|
||||||
})
|
|
||||||
pc_lookup[ptr] = v
|
|
||||||
if v >= 0 {
|
|
||||||
mark_lookup[v] = f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setEntries(markS, -0x1)
|
|
||||||
setEntries(mark0, 0x0)
|
|
||||||
setEntries(mark1, 0x1)
|
|
||||||
setEntries(mark2, 0x2)
|
|
||||||
setEntries(mark3, 0x3)
|
|
||||||
setEntries(mark4, 0x4)
|
|
||||||
setEntries(mark5, 0x5)
|
|
||||||
setEntries(mark6, 0x6)
|
|
||||||
setEntries(mark7, 0x7)
|
|
||||||
setEntries(mark8, 0x8)
|
|
||||||
setEntries(mark9, 0x9)
|
|
||||||
setEntries(markA, 0xa)
|
|
||||||
setEntries(markB, 0xb)
|
|
||||||
setEntries(markC, 0xc)
|
|
||||||
setEntries(markD, 0xd)
|
|
||||||
setEntries(markE, 0xe)
|
|
||||||
setEntries(markF, 0xf)
|
|
||||||
}
|
|
||||||
|
|
||||||
func currentStack(skip int) (stack []uintptr) {
|
|
||||||
jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n")
|
|
||||||
for i := skip + 2; i < jsStack.Get("length").Int(); i++ {
|
|
||||||
item := jsStack.Index(i).String()
|
|
||||||
matches := stackRE.FindAllStringSubmatch(item, -1)
|
|
||||||
if matches == nil {
|
|
||||||
return stack
|
|
||||||
}
|
|
||||||
line, _ := strconv.Atoi(matches[0][2])
|
|
||||||
char, _ := strconv.Atoi(matches[0][3])
|
|
||||||
x := (uintptr(line) << 16) | uintptr(char)&0xffff
|
|
||||||
stack = append(stack, x)
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack
|
|
||||||
}
|
|
||||||
|
|
||||||
func readStackTags(skip int) (tags []uint) {
|
|
||||||
stack := currentStack(skip)
|
|
||||||
var current_tag uint
|
|
||||||
for _, pc := range stack {
|
|
||||||
val, ok := pc_lookup[pc]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if val < 0 {
|
|
||||||
tags = append(tags, current_tag)
|
|
||||||
current_tag = 0
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
current_tag <<= bitWidth
|
|
||||||
current_tag += uint(val)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
61
vendor/github.com/jtolds/gls/stack_tags_main.go
generated
vendored
61
vendor/github.com/jtolds/gls/stack_tags_main.go
generated
vendored
|
@ -1,61 +0,0 @@
|
||||||
// +build !js
|
|
||||||
|
|
||||||
package gls
|
|
||||||
|
|
||||||
// This file is used for standard Go builds, which have the expected runtime support
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
setEntries := func(f func(uint, func()), v int8) {
|
|
||||||
pc_lookup[reflect.ValueOf(f).Pointer()] = v
|
|
||||||
if v >= 0 {
|
|
||||||
mark_lookup[v] = f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setEntries(markS, -0x1)
|
|
||||||
setEntries(mark0, 0x0)
|
|
||||||
setEntries(mark1, 0x1)
|
|
||||||
setEntries(mark2, 0x2)
|
|
||||||
setEntries(mark3, 0x3)
|
|
||||||
setEntries(mark4, 0x4)
|
|
||||||
setEntries(mark5, 0x5)
|
|
||||||
setEntries(mark6, 0x6)
|
|
||||||
setEntries(mark7, 0x7)
|
|
||||||
setEntries(mark8, 0x8)
|
|
||||||
setEntries(mark9, 0x9)
|
|
||||||
setEntries(markA, 0xa)
|
|
||||||
setEntries(markB, 0xb)
|
|
||||||
setEntries(markC, 0xc)
|
|
||||||
setEntries(markD, 0xd)
|
|
||||||
setEntries(markE, 0xe)
|
|
||||||
setEntries(markF, 0xf)
|
|
||||||
}
|
|
||||||
|
|
||||||
func currentStack(skip int) []uintptr {
|
|
||||||
stack := make([]uintptr, maxCallers)
|
|
||||||
return stack[:runtime.Callers(3+skip, stack)]
|
|
||||||
}
|
|
||||||
|
|
||||||
func readStackTags(skip int) (tags []uint) {
|
|
||||||
stack := currentStack(skip)
|
|
||||||
var current_tag uint
|
|
||||||
for _, pc := range stack {
|
|
||||||
pc = runtime.FuncForPC(pc).Entry()
|
|
||||||
val, ok := pc_lookup[pc]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if val < 0 {
|
|
||||||
tags = append(tags, current_tag)
|
|
||||||
current_tag = 0
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
current_tag <<= bitWidth
|
|
||||||
current_tag += uint(val)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
28
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
28
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
|
@ -1,28 +0,0 @@
|
||||||
// Package require implements the same assertions as the `assert` package but
|
|
||||||
// stops test execution when a test fails.
|
|
||||||
//
|
|
||||||
// Example Usage
|
|
||||||
//
|
|
||||||
// The following is a complete example using require in a standard test function:
|
|
||||||
// import (
|
|
||||||
// "testing"
|
|
||||||
// "github.com/stretchr/testify/require"
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// func TestSomething(t *testing.T) {
|
|
||||||
//
|
|
||||||
// var a string = "Hello"
|
|
||||||
// var b string = "Hello"
|
|
||||||
//
|
|
||||||
// require.Equal(t, a, b, "The two words should be the same.")
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Assertions
|
|
||||||
//
|
|
||||||
// The `require` package have same global functions as in the `assert` package,
|
|
||||||
// but instead of returning a boolean result they call `t.FailNow()`.
|
|
||||||
//
|
|
||||||
// Every assertion function also takes an optional string message as the final argument,
|
|
||||||
// allowing custom error messages to be appended to the message the assertion method outputs.
|
|
||||||
package require
|
|
16
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
16
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
|
@ -1,16 +0,0 @@
|
||||||
package require
|
|
||||||
|
|
||||||
// Assertions provides assertion methods around the
|
|
||||||
// TestingT interface.
|
|
||||||
type Assertions struct {
|
|
||||||
t TestingT
|
|
||||||
}
|
|
||||||
|
|
||||||
// New makes a new Assertions object for the specified TestingT.
|
|
||||||
func New(t TestingT) *Assertions {
|
|
||||||
return &Assertions{
|
|
||||||
t: t,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl
|
|
429
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
429
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
|
@ -1,429 +0,0 @@
|
||||||
/*
|
|
||||||
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
|
||||||
* THIS FILE MUST NOT BE EDITED BY HAND
|
|
||||||
*/
|
|
||||||
|
|
||||||
package require
|
|
||||||
|
|
||||||
import (
|
|
||||||
assert "github.com/stretchr/testify/assert"
|
|
||||||
http "net/http"
|
|
||||||
url "net/url"
|
|
||||||
time "time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Condition uses a Comparison to assert a complex condition.
|
|
||||||
func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Condition(t, comp, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
|
||||||
// specified substring or element.
|
|
||||||
//
|
|
||||||
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
|
|
||||||
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
|
||||||
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Contains(t, s, contains, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
|
||||||
// a slice or a channel with len == 0.
|
|
||||||
//
|
|
||||||
// assert.Empty(t, obj)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Empty(t, object, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
|
||||||
//
|
|
||||||
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
//
|
|
||||||
// Pointer variable equality is determined based on the equality of the
|
|
||||||
// referenced values (as opposed to the memory addresses).
|
|
||||||
func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Equal(t, expected, actual, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
|
||||||
// and that it is equal to the provided error.
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// assert.EqualError(t, err, expectedErrorString, "An error was expected")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.EqualError(t, theError, errString, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
|
||||||
// and equal.
|
|
||||||
//
|
|
||||||
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// if assert.Error(t, err, "An error was expected") {
|
|
||||||
// assert.Equal(t, err, expectedError)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Error(t TestingT, err error, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Error(t, err, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
|
||||||
//
|
|
||||||
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Exactly(t, expected, actual, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fail reports a failure through
|
|
||||||
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Fail(t, failureMessage, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FailNow fails test
|
|
||||||
func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.FailNow(t, failureMessage, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
|
||||||
//
|
|
||||||
// assert.False(t, myBool, "myBool should be false")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.False(t, value, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPBodyContains asserts that a specified handler returns a
|
|
||||||
// body that contains a string.
|
|
||||||
//
|
|
||||||
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
|
||||||
//
|
|
||||||
// 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{}) {
|
|
||||||
if !assert.HTTPBodyContains(t, handler, method, url, values, str) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPBodyNotContains asserts that a specified handler returns a
|
|
||||||
// body that does not contain a string.
|
|
||||||
//
|
|
||||||
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
|
||||||
//
|
|
||||||
// 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{}) {
|
|
||||||
if !assert.HTTPBodyNotContains(t, handler, method, url, values, str) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPError asserts that a specified handler returns an error status code.
|
|
||||||
//
|
|
||||||
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
if !assert.HTTPError(t, handler, method, url, values) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
|
||||||
//
|
|
||||||
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
if !assert.HTTPRedirect(t, handler, method, url, values) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPSuccess asserts that a specified handler returns a success status code.
|
|
||||||
//
|
|
||||||
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
if !assert.HTTPSuccess(t, handler, method, url, values) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
|
||||||
//
|
|
||||||
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
|
|
||||||
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InDelta asserts that the two numerals are within delta of each other.
|
|
||||||
//
|
|
||||||
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
|
|
||||||
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...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
|
|
||||||
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...) {
|
|
||||||
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...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONEq asserts that two JSON strings are equivalent.
|
|
||||||
//
|
|
||||||
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Len asserts that the specified object has specific length.
|
|
||||||
// Len also fails if the object has a type that len() not accept.
|
|
||||||
//
|
|
||||||
// assert.Len(t, mySlice, 3, "The size of slice is not 3")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Len(t, object, length, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
|
||||||
//
|
|
||||||
// assert.Nil(t, err, "err should be nothing")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Nil(t, object, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NoError asserts that a function returned no error (i.e. `nil`).
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// if assert.NoError(t, err) {
|
|
||||||
// assert.Equal(t, actualObj, expectedObj)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NoError(t, err, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
|
||||||
// specified substring or element.
|
|
||||||
//
|
|
||||||
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
|
||||||
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
|
||||||
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotContains(t, s, contains, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
|
||||||
// a slice or a channel with len == 0.
|
|
||||||
//
|
|
||||||
// if assert.NotEmpty(t, obj) {
|
|
||||||
// assert.Equal(t, "two", obj[1])
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotEmpty(t, object, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
|
||||||
//
|
|
||||||
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
//
|
|
||||||
// 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...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
|
||||||
//
|
|
||||||
// assert.NotNil(t, err, "err should be something")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotNil(t, object, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
|
||||||
//
|
|
||||||
// assert.NotPanics(t, func(){
|
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotPanics(t, f, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotRegexp asserts that a specified regexp does not match a string.
|
|
||||||
//
|
|
||||||
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
|
|
||||||
// assert.NotRegexp(t, "^start", "it's not starting")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
|
||||||
func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.NotZero(t, i, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
|
||||||
//
|
|
||||||
// assert.Panics(t, func(){
|
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Panics(t, f, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regexp asserts that a specified regexp matches a string.
|
|
||||||
//
|
|
||||||
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
|
|
||||||
// assert.Regexp(t, "start...$", "it's not starting")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Regexp(t, rx, str, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
|
||||||
//
|
|
||||||
// assert.True(t, myBool, "myBool should be true")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.True(t, value, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
|
||||||
//
|
|
||||||
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zero asserts that i is the zero value for its type and returns the truth.
|
|
||||||
func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
|
||||||
if !assert.Zero(t, i, msgAndArgs...) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
6
vendor/github.com/stretchr/testify/require/require.go.tmpl
generated
vendored
6
vendor/github.com/stretchr/testify/require/require.go.tmpl
generated
vendored
|
@ -1,6 +0,0 @@
|
||||||
{{.Comment}}
|
|
||||||
func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
|
|
||||||
if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
353
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
353
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
|
@ -1,353 +0,0 @@
|
||||||
/*
|
|
||||||
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
|
||||||
* THIS FILE MUST NOT BE EDITED BY HAND
|
|
||||||
*/
|
|
||||||
|
|
||||||
package require
|
|
||||||
|
|
||||||
import (
|
|
||||||
assert "github.com/stretchr/testify/assert"
|
|
||||||
http "net/http"
|
|
||||||
url "net/url"
|
|
||||||
time "time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Condition uses a Comparison to assert a complex condition.
|
|
||||||
func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
|
|
||||||
Condition(a.t, comp, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
|
||||||
// specified substring or element.
|
|
||||||
//
|
|
||||||
// a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
|
|
||||||
// a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
|
||||||
// a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Contains(a.t, s, contains, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
|
||||||
// a slice or a channel with len == 0.
|
|
||||||
//
|
|
||||||
// a.Empty(obj)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Empty(a.t, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
|
||||||
//
|
|
||||||
// a.Equal(123, 123, "123 and 123 should be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
//
|
|
||||||
// Pointer variable equality is determined based on the equality of the
|
|
||||||
// referenced values (as opposed to the memory addresses).
|
|
||||||
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Equal(a.t, expected, actual, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
|
||||||
// and that it is equal to the provided error.
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// a.EqualError(err, expectedErrorString, "An error was expected")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
|
|
||||||
EqualError(a.t, theError, errString, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
|
||||||
// and equal.
|
|
||||||
//
|
|
||||||
// a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
EqualValues(a.t, expected, actual, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// if a.Error(err, "An error was expected") {
|
|
||||||
// assert.Equal(t, err, expectedError)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
|
|
||||||
Error(a.t, err, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
|
||||||
//
|
|
||||||
// a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Exactly(a.t, expected, actual, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fail reports a failure through
|
|
||||||
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
|
|
||||||
Fail(a.t, failureMessage, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FailNow fails test
|
|
||||||
func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
|
|
||||||
FailNow(a.t, failureMessage, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
|
||||||
//
|
|
||||||
// a.False(myBool, "myBool should be false")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
|
|
||||||
False(a.t, value, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPBodyContains asserts that a specified handler returns a
|
|
||||||
// body that contains a string.
|
|
||||||
//
|
|
||||||
// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
|
||||||
HTTPBodyContains(a.t, handler, method, url, values, str)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPBodyNotContains asserts that a specified handler returns a
|
|
||||||
// body that does not contain a string.
|
|
||||||
//
|
|
||||||
// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
|
||||||
HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPError asserts that a specified handler returns an error status code.
|
|
||||||
//
|
|
||||||
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
HTTPError(a.t, handler, method, url, values)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
|
||||||
//
|
|
||||||
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
HTTPRedirect(a.t, handler, method, url, values)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPSuccess asserts that a specified handler returns a success status code.
|
|
||||||
//
|
|
||||||
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
|
|
||||||
HTTPSuccess(a.t, handler, method, url, values)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
|
||||||
//
|
|
||||||
// a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
|
|
||||||
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Implements(a.t, interfaceObject, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InDelta asserts that the two numerals are within delta of each other.
|
|
||||||
//
|
|
||||||
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
|
||||||
InDelta(a.t, expected, actual, delta, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InDeltaSlice is the same as InDelta, except it compares two slices.
|
|
||||||
func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
|
||||||
InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
|
||||||
InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
|
|
||||||
func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
|
||||||
InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsType asserts that the specified objects are of the same type.
|
|
||||||
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
IsType(a.t, expectedType, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONEq asserts that two JSON strings are equivalent.
|
|
||||||
//
|
|
||||||
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
|
|
||||||
JSONEq(a.t, expected, actual, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Len asserts that the specified object has specific length.
|
|
||||||
// Len also fails if the object has a type that len() not accept.
|
|
||||||
//
|
|
||||||
// a.Len(mySlice, 3, "The size of slice is not 3")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
|
|
||||||
Len(a.t, object, length, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
|
||||||
//
|
|
||||||
// a.Nil(err, "err should be nothing")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Nil(a.t, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NoError asserts that a function returned no error (i.e. `nil`).
|
|
||||||
//
|
|
||||||
// actualObj, err := SomeFunction()
|
|
||||||
// if a.NoError(err) {
|
|
||||||
// assert.Equal(t, actualObj, expectedObj)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
|
|
||||||
NoError(a.t, err, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
|
||||||
// specified substring or element.
|
|
||||||
//
|
|
||||||
// a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
|
||||||
// a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
|
||||||
// a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotContains(a.t, s, contains, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
|
||||||
// a slice or a channel with len == 0.
|
|
||||||
//
|
|
||||||
// if a.NotEmpty(obj) {
|
|
||||||
// assert.Equal(t, "two", obj[1])
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotEmpty(a.t, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
|
||||||
//
|
|
||||||
// a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
//
|
|
||||||
// Pointer variable equality is determined based on the equality of the
|
|
||||||
// referenced values (as opposed to the memory addresses).
|
|
||||||
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotEqual(a.t, expected, actual, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
|
||||||
//
|
|
||||||
// a.NotNil(err, "err should be something")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotNil(a.t, object, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
|
||||||
//
|
|
||||||
// a.NotPanics(func(){
|
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
|
||||||
NotPanics(a.t, f, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotRegexp asserts that a specified regexp does not match a string.
|
|
||||||
//
|
|
||||||
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
|
||||||
// a.NotRegexp("^start", "it's not starting")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotRegexp(a.t, rx, str, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
|
||||||
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
|
|
||||||
NotZero(a.t, i, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
|
||||||
//
|
|
||||||
// a.Panics(func(){
|
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
|
||||||
Panics(a.t, f, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regexp asserts that a specified regexp matches a string.
|
|
||||||
//
|
|
||||||
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
|
||||||
// a.Regexp("start...$", "it's not starting")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Regexp(a.t, rx, str, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
|
||||||
//
|
|
||||||
// a.True(myBool, "myBool should be true")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
|
|
||||||
True(a.t, value, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
|
||||||
//
|
|
||||||
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
|
||||||
//
|
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
|
||||||
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
|
||||||
WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zero asserts that i is the zero value for its type and returns the truth.
|
|
||||||
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
|
|
||||||
Zero(a.t, i, msgAndArgs...)
|
|
||||||
}
|
|
4
vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
generated
vendored
4
vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
generated
vendored
|
@ -1,4 +0,0 @@
|
||||||
{{.CommentWithoutT "a"}}
|
|
||||||
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
|
|
||||||
{{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
|
|
||||||
}
|
|
9
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
9
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
|
@ -1,9 +0,0 @@
|
||||||
package require
|
|
||||||
|
|
||||||
// TestingT is an interface wrapper around *testing.T
|
|
||||||
type TestingT interface {
|
|
||||||
Errorf(format string, args ...interface{})
|
|
||||||
FailNow()
|
|
||||||
}
|
|
||||||
|
|
||||||
//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl
|
|
18
vendor/vendor.json
vendored
18
vendor/vendor.json
vendored
|
@ -485,12 +485,6 @@
|
||||||
"revision": "5f1c01d9f64b941dd9582c638279d046eda6ca31",
|
"revision": "5f1c01d9f64b941dd9582c638279d046eda6ca31",
|
||||||
"revisionTime": "2016-03-04T05:48:22Z"
|
"revisionTime": "2016-03-04T05:48:22Z"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"checksumSHA1": "P3zGmsNjW8m15a+nks4FdVpFKwE=",
|
|
||||||
"path": "github.com/gopherjs/gopherjs/js",
|
|
||||||
"revision": "e34a5cd6a1bc7c4fde759f2d3039852fc68b5fcc",
|
|
||||||
"revisionTime": "2016-10-31T10:43:57Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"checksumSHA1": "MLO0PyrK2MUO6A7Z9PxWuu43C/A=",
|
"checksumSHA1": "MLO0PyrK2MUO6A7Z9PxWuu43C/A=",
|
||||||
"path": "github.com/issue9/identicon",
|
"path": "github.com/issue9/identicon",
|
||||||
|
@ -503,12 +497,6 @@
|
||||||
"revision": "8fb95d837f7d6db1913fecfd7bcc5333e6499596",
|
"revision": "8fb95d837f7d6db1913fecfd7bcc5333e6499596",
|
||||||
"revisionTime": "2016-09-23T19:14:38Z"
|
"revisionTime": "2016-09-23T19:14:38Z"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"checksumSHA1": "tewA7jXVGCw1zb5mA0BDecWi4iQ=",
|
|
||||||
"path": "github.com/jtolds/gls",
|
|
||||||
"revision": "8ddce2a84170772b95dd5d576c48d517b22cac63",
|
|
||||||
"revisionTime": "2016-01-05T22:08:40Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"checksumSHA1": "KIX/3RadQkfl4ZxCmOQ01vAGLEI=",
|
"checksumSHA1": "KIX/3RadQkfl4ZxCmOQ01vAGLEI=",
|
||||||
"path": "github.com/juju/errors",
|
"path": "github.com/juju/errors",
|
||||||
|
@ -1038,12 +1026,6 @@
|
||||||
"revision": "976c720a22c8eb4eb6a0b4348ad85ad12491a506",
|
"revision": "976c720a22c8eb4eb6a0b4348ad85ad12491a506",
|
||||||
"revisionTime": "2016-09-25T22:06:09Z"
|
"revisionTime": "2016-09-25T22:06:09Z"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"checksumSHA1": "2PpOCNkWnshDrXeCVH2kp3VHhIM=",
|
|
||||||
"path": "github.com/stretchr/testify/require",
|
|
||||||
"revision": "2402e8e7a02fc811447d11f881aa9746cdc57983",
|
|
||||||
"revisionTime": "2016-12-17T20:04:45Z"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"checksumSHA1": "MAnxhGyQfhoyoATeT1zJDPyWq7A=",
|
"checksumSHA1": "MAnxhGyQfhoyoATeT1zJDPyWq7A=",
|
||||||
"path": "github.com/syndtr/goleveldb/leveldb",
|
"path": "github.com/syndtr/goleveldb/leveldb",
|
||||||
|
|
Loading…
Reference in a new issue