Documentation
¶
Index ¶
- type AddrInvocation
- type DebugServer
- type FakeServer
- func (_f2 *FakeServer) Addr() (ident44 string)
- func (f *FakeServer) AddrCalled() bool
- func (f *FakeServer) AddrCalledN(n int) bool
- func (f *FakeServer) AddrCalledOnce() bool
- func (f *FakeServer) AddrNotCalled() bool
- func (f *FakeServer) AssertAddrCalled(t *testing.T)
- func (f *FakeServer) AssertAddrCalledN(t *testing.T, n int)
- func (f *FakeServer) AssertAddrCalledOnce(t *testing.T)
- func (f *FakeServer) AssertAddrNotCalled(t *testing.T)
- func (f *FakeServer) AssertNameCalled(t *testing.T)
- func (f *FakeServer) AssertNameCalledN(t *testing.T, n int)
- func (f *FakeServer) AssertNameCalledOnce(t *testing.T)
- func (f *FakeServer) AssertNameNotCalled(t *testing.T)
- func (f *FakeServer) AssertServeCalled(t *testing.T)
- func (f *FakeServer) AssertServeCalledN(t *testing.T, n int)
- func (f *FakeServer) AssertServeCalledOnce(t *testing.T)
- func (f *FakeServer) AssertServeNotCalled(t *testing.T)
- func (f *FakeServer) AssertShutdownCalled(t *testing.T)
- func (f *FakeServer) AssertShutdownCalledN(t *testing.T, n int)
- func (f *FakeServer) AssertShutdownCalledOnce(t *testing.T)
- func (_f8 *FakeServer) AssertShutdownCalledOnceWith(t *testing.T, ident46 time.Duration)
- func (_f6 *FakeServer) AssertShutdownCalledWith(t *testing.T, ident46 time.Duration)
- func (f *FakeServer) AssertShutdownNotCalled(t *testing.T)
- func (_f1 *FakeServer) Name() (ident43 string)
- func (f *FakeServer) NameCalled() bool
- func (f *FakeServer) NameCalledN(n int) bool
- func (f *FakeServer) NameCalledOnce() bool
- func (f *FakeServer) NameNotCalled() bool
- func (_f3 *FakeServer) Serve() (ident45 error)
- func (f *FakeServer) ServeCalled() bool
- func (f *FakeServer) ServeCalledN(n int) bool
- func (f *FakeServer) ServeCalledOnce() bool
- func (f *FakeServer) ServeNotCalled() bool
- func (_f4 *FakeServer) Shutdown(ident46 time.Duration) (ident47 error)
- func (f *FakeServer) ShutdownCalled() bool
- func (f *FakeServer) ShutdownCalledN(n int) bool
- func (f *FakeServer) ShutdownCalledOnce() bool
- func (_f7 *FakeServer) ShutdownCalledOnceWith(ident46 time.Duration) bool
- func (_f5 *FakeServer) ShutdownCalledWith(ident46 time.Duration) (found bool)
- func (f *FakeServer) ShutdownNotCalled() bool
- func (_f9 *FakeServer) ShutdownResultsForCall(ident46 time.Duration) (ident47 error, found bool)
- type NameInvocation
- type ServeInvocation
- type Server
- type ShutdownInvocation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddrInvocation ¶
type AddrInvocation struct {
Results struct {
Ident44 string
}
}
AddrInvocation represents a single call of FakeServer.Addr
type DebugServer ¶
type DebugServer struct {
Path string // URL path to listen on, "/debug/vars" if empty
Address string // TCP address to listen on, ":http" if empty
UseTLS bool // should this server use TLS?
DisableKeepAlive bool // Should TCP keep alive be disabled?
TLSConfig *tls.Config // optional TLS config, used by ServeTLS and ListenAndServeTLS
// ReadTimeout is the maximum duration for reading the entire
// request, including the body.
//
// Because ReadTimeout does not let Handlers make per-request
// decisions on each request body's acceptable deadline or
// upload rate, most users will prefer to use
// ReadHeaderTimeout. It is valid to use them both.
ReadTimeout time.Duration
// ReadHeaderTimeout is the amount of time allowed to read
// request headers. The connection's read deadline is reset
// after reading the headers and the Handler can decide what
// is considered too slow for the body.
ReadHeaderTimeout time.Duration
// WriteTimeout is the maximum duration before timing out
// writes of the response. It is reset whenever a new
// request's header is read. Like ReadTimeout, it does not
// let Handlers make decisions on a per-request basis.
WriteTimeout time.Duration
// IdleTimeout is the maximum amount of time to wait for the
// next request when keep-alives are enabled. If IdleTimeout
// is zero, the value of ReadTimeout is used. If both are
// zero, ReadHeaderTimeout is used.
IdleTimeout time.Duration
// MaxHeaderBytes controls the maximum number of bytes the
// server will read parsing the request header's keys and
// values, including the request line. It does not limit the
// size of the request body.
// If zero, DefaultMaxHeaderBytes is used.
MaxHeaderBytes int
// TLSNextProto optionally specifies a function to take over
// ownership of the provided TLS connection when an NPN/ALPN
// protocol upgrade has occurred. The map key is the protocol
// name negotiated. The Handler argument should be used to
// handle HTTP requests and will initialize the Request's TLS
// and RemoteAddr if not already set. The connection is
// automatically closed when the function returns.
// If TLSNextProto is not nil, HTTP/2 support is not enabled
// automatically.
TLSNextProto map[string]func(*http.Server, *tls.Conn, http.Handler)
Logger *zap.Logger
// contains filtered or unexported fields
}
func (*DebugServer) Addr ¶
func (s *DebugServer) Addr() string
func (*DebugServer) Name ¶
func (s *DebugServer) Name() string
func (*DebugServer) Serve ¶
func (s *DebugServer) Serve() error
type FakeServer ¶
type FakeServer struct {
NameHook func() string
AddrHook func() string
ServeHook func() error
ShutdownHook func(time.Duration) error
NameCalls []*NameInvocation
AddrCalls []*AddrInvocation
ServeCalls []*ServeInvocation
ShutdownCalls []*ShutdownInvocation
}
FakeServer is a mock implementation of Server for testing. Use it in your tests as in this example:
package example
func TestWithServer(t *testing.T) {
f := &auxillary.FakeServer{
NameHook: func() (ident43 string) {
// ensure parameters meet expections, signal errors using t, etc
return
},
}
// test code goes here ...
// assert state of FakeName ...
f.AssertNameCalledOnce(t)
}
Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeName.
func NewFakeServerDefaultError ¶
func NewFakeServerDefaultError(t *testing.T) *FakeServer
NewFakeServerDefaultError returns an instance of FakeServer with all hooks configured to call t.Error
func NewFakeServerDefaultFatal ¶
func NewFakeServerDefaultFatal(t *testing.T) *FakeServer
NewFakeServerDefaultFatal returns an instance of FakeServer with all hooks configured to call t.Fatal
func NewFakeServerDefaultPanic ¶
func NewFakeServerDefaultPanic() *FakeServer
NewFakeServerDefaultPanic returns an instance of FakeServer with all hooks configured to panic
func (*FakeServer) Addr ¶
func (_f2 *FakeServer) Addr() (ident44 string)
func (*FakeServer) AddrCalled ¶
func (f *FakeServer) AddrCalled() bool
AddrCalled returns true if FakeServer.Addr was called
func (*FakeServer) AddrCalledN ¶
func (f *FakeServer) AddrCalledN(n int) bool
AddrCalledN returns true if FakeServer.Addr was called at least n times
func (*FakeServer) AddrCalledOnce ¶
func (f *FakeServer) AddrCalledOnce() bool
AddrCalledOnce returns true if FakeServer.Addr was called exactly once
func (*FakeServer) AddrNotCalled ¶
func (f *FakeServer) AddrNotCalled() bool
AddrNotCalled returns true if FakeServer.Addr was not called
func (*FakeServer) AssertAddrCalled ¶
func (f *FakeServer) AssertAddrCalled(t *testing.T)
AssertAddrCalled calls t.Error if FakeServer.Addr was not called
func (*FakeServer) AssertAddrCalledN ¶
func (f *FakeServer) AssertAddrCalledN(t *testing.T, n int)
AssertAddrCalledN calls t.Error if FakeServer.Addr was called less than n times
func (*FakeServer) AssertAddrCalledOnce ¶
func (f *FakeServer) AssertAddrCalledOnce(t *testing.T)
AssertAddrCalledOnce calls t.Error if FakeServer.Addr was not called exactly once
func (*FakeServer) AssertAddrNotCalled ¶
func (f *FakeServer) AssertAddrNotCalled(t *testing.T)
AssertAddrNotCalled calls t.Error if FakeServer.Addr was called
func (*FakeServer) AssertNameCalled ¶
func (f *FakeServer) AssertNameCalled(t *testing.T)
AssertNameCalled calls t.Error if FakeServer.Name was not called
func (*FakeServer) AssertNameCalledN ¶
func (f *FakeServer) AssertNameCalledN(t *testing.T, n int)
AssertNameCalledN calls t.Error if FakeServer.Name was called less than n times
func (*FakeServer) AssertNameCalledOnce ¶
func (f *FakeServer) AssertNameCalledOnce(t *testing.T)
AssertNameCalledOnce calls t.Error if FakeServer.Name was not called exactly once
func (*FakeServer) AssertNameNotCalled ¶
func (f *FakeServer) AssertNameNotCalled(t *testing.T)
AssertNameNotCalled calls t.Error if FakeServer.Name was called
func (*FakeServer) AssertServeCalled ¶
func (f *FakeServer) AssertServeCalled(t *testing.T)
AssertServeCalled calls t.Error if FakeServer.Serve was not called
func (*FakeServer) AssertServeCalledN ¶
func (f *FakeServer) AssertServeCalledN(t *testing.T, n int)
AssertServeCalledN calls t.Error if FakeServer.Serve was called less than n times
func (*FakeServer) AssertServeCalledOnce ¶
func (f *FakeServer) AssertServeCalledOnce(t *testing.T)
AssertServeCalledOnce calls t.Error if FakeServer.Serve was not called exactly once
func (*FakeServer) AssertServeNotCalled ¶
func (f *FakeServer) AssertServeNotCalled(t *testing.T)
AssertServeNotCalled calls t.Error if FakeServer.Serve was called
func (*FakeServer) AssertShutdownCalled ¶
func (f *FakeServer) AssertShutdownCalled(t *testing.T)
AssertShutdownCalled calls t.Error if FakeServer.Shutdown was not called
func (*FakeServer) AssertShutdownCalledN ¶
func (f *FakeServer) AssertShutdownCalledN(t *testing.T, n int)
AssertShutdownCalledN calls t.Error if FakeServer.Shutdown was called less than n times
func (*FakeServer) AssertShutdownCalledOnce ¶
func (f *FakeServer) AssertShutdownCalledOnce(t *testing.T)
AssertShutdownCalledOnce calls t.Error if FakeServer.Shutdown was not called exactly once
func (*FakeServer) AssertShutdownCalledOnceWith ¶
func (_f8 *FakeServer) AssertShutdownCalledOnceWith(t *testing.T, ident46 time.Duration)
AssertShutdownCalledOnceWith calls t.Error if FakeServer.Shutdown was not called exactly once with the given values
func (*FakeServer) AssertShutdownCalledWith ¶
func (_f6 *FakeServer) AssertShutdownCalledWith(t *testing.T, ident46 time.Duration)
AssertShutdownCalledWith calls t.Error if FakeServer.Shutdown was not called with the given values
func (*FakeServer) AssertShutdownNotCalled ¶
func (f *FakeServer) AssertShutdownNotCalled(t *testing.T)
AssertShutdownNotCalled calls t.Error if FakeServer.Shutdown was called
func (*FakeServer) Name ¶
func (_f1 *FakeServer) Name() (ident43 string)
func (*FakeServer) NameCalled ¶
func (f *FakeServer) NameCalled() bool
NameCalled returns true if FakeServer.Name was called
func (*FakeServer) NameCalledN ¶
func (f *FakeServer) NameCalledN(n int) bool
NameCalledN returns true if FakeServer.Name was called at least n times
func (*FakeServer) NameCalledOnce ¶
func (f *FakeServer) NameCalledOnce() bool
NameCalledOnce returns true if FakeServer.Name was called exactly once
func (*FakeServer) NameNotCalled ¶
func (f *FakeServer) NameNotCalled() bool
NameNotCalled returns true if FakeServer.Name was not called
func (*FakeServer) Serve ¶
func (_f3 *FakeServer) Serve() (ident45 error)
func (*FakeServer) ServeCalled ¶
func (f *FakeServer) ServeCalled() bool
ServeCalled returns true if FakeServer.Serve was called
func (*FakeServer) ServeCalledN ¶
func (f *FakeServer) ServeCalledN(n int) bool
ServeCalledN returns true if FakeServer.Serve was called at least n times
func (*FakeServer) ServeCalledOnce ¶
func (f *FakeServer) ServeCalledOnce() bool
ServeCalledOnce returns true if FakeServer.Serve was called exactly once
func (*FakeServer) ServeNotCalled ¶
func (f *FakeServer) ServeNotCalled() bool
ServeNotCalled returns true if FakeServer.Serve was not called
func (*FakeServer) Shutdown ¶
func (_f4 *FakeServer) Shutdown(ident46 time.Duration) (ident47 error)
func (*FakeServer) ShutdownCalled ¶
func (f *FakeServer) ShutdownCalled() bool
ShutdownCalled returns true if FakeServer.Shutdown was called
func (*FakeServer) ShutdownCalledN ¶
func (f *FakeServer) ShutdownCalledN(n int) bool
ShutdownCalledN returns true if FakeServer.Shutdown was called at least n times
func (*FakeServer) ShutdownCalledOnce ¶
func (f *FakeServer) ShutdownCalledOnce() bool
ShutdownCalledOnce returns true if FakeServer.Shutdown was called exactly once
func (*FakeServer) ShutdownCalledOnceWith ¶
func (_f7 *FakeServer) ShutdownCalledOnceWith(ident46 time.Duration) bool
ShutdownCalledOnceWith returns true if FakeServer.Shutdown was called exactly once with the given values
func (*FakeServer) ShutdownCalledWith ¶
func (_f5 *FakeServer) ShutdownCalledWith(ident46 time.Duration) (found bool)
ShutdownCalledWith returns true if FakeServer.Shutdown was called with the given values
func (*FakeServer) ShutdownNotCalled ¶
func (f *FakeServer) ShutdownNotCalled() bool
ShutdownNotCalled returns true if FakeServer.Shutdown was not called
func (*FakeServer) ShutdownResultsForCall ¶
func (_f9 *FakeServer) ShutdownResultsForCall(ident46 time.Duration) (ident47 error, found bool)
ShutdownResultsForCall returns the result values for the first call to FakeServer.Shutdown with the given values
type NameInvocation ¶
type NameInvocation struct {
Results struct {
Ident43 string
}
}
NameInvocation represents a single call of FakeServer.Name
type ServeInvocation ¶
type ServeInvocation struct {
Results struct {
Ident45 error
}
}
ServeInvocation represents a single call of FakeServer.Serve
type ShutdownInvocation ¶
type ShutdownInvocation struct {
Parameters struct {
Ident46 time.Duration
}
Results struct {
Ident47 error
}
}
ShutdownInvocation represents a single call of FakeServer.Shutdown