context

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2017 License: BSD-3-Clause Imports: 5 Imported by: 11

Documentation

Index

Constants

View Source
const (
	IDKey    = "ContextRequestIDKey"
	ActorKey = "ContextActorKey"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorInvocation

type ActorInvocation struct {
	Results struct {
		Ident7 models.User
	}
}

ActorInvocation represents a single call of FakeContext.Actor

type Context

type Context interface {
	context.Context
	RequestID() string
	SetRequestID(v string)
	Actor() models.User
	SetActor(v models.User)
}

func New

func New(parent context.Context) Context

type DeadlineInvocation

type DeadlineInvocation struct {
	Results struct {
		Deadline time.Time
		Ok       bool
	}
}

DeadlineInvocation represents a single call of FakeContext.Deadline

type DoneInvocation

type DoneInvocation struct {
	Results struct {
		Ident1 <-chan struct{}
	}
}

DoneInvocation represents a single call of FakeContext.Done

type ErrInvocation

type ErrInvocation struct {
	Results struct {
		Ident2 error
	}
}

ErrInvocation represents a single call of FakeContext.Err

type FakeContext

type FakeContext struct {
	DeadlineHook     func() (time.Time, bool)
	DoneHook         func() <-chan struct{}
	ErrHook          func() error
	ValueHook        func(interface{}) interface{}
	RequestIDHook    func() string
	SetRequestIDHook func(string)
	ActorHook        func() models.User
	SetActorHook     func(models.User)

	DeadlineCalls     []*DeadlineInvocation
	DoneCalls         []*DoneInvocation
	ErrCalls          []*ErrInvocation
	ValueCalls        []*ValueInvocation
	RequestIDCalls    []*RequestIDInvocation
	SetRequestIDCalls []*SetRequestIDInvocation
	ActorCalls        []*ActorInvocation
	SetActorCalls     []*SetActorInvocation
}

FakeContext is a mock implementation of Context for testing. Use it in your tests as in this example:

package example

func TestWithContext(t *testing.T) {
	f := &context.FakeContext{
		DeadlineHook: func() (deadline time.Time, ok bool) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeDeadline ...
	f.AssertDeadlineCalledOnce(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 FakeDeadline.

func NewFakeContextDefaultError

func NewFakeContextDefaultError(t *testing.T) *FakeContext

NewFakeContextDefaultError returns an instance of FakeContext with all hooks configured to call t.Error

func NewFakeContextDefaultFatal

func NewFakeContextDefaultFatal(t *testing.T) *FakeContext

NewFakeContextDefaultFatal returns an instance of FakeContext with all hooks configured to call t.Fatal

func NewFakeContextDefaultPanic

func NewFakeContextDefaultPanic() *FakeContext

NewFakeContextDefaultPanic returns an instance of FakeContext with all hooks configured to panic

func (*FakeContext) Actor

func (_f16 *FakeContext) Actor() (ident7 models.User)

func (*FakeContext) ActorCalled

func (f *FakeContext) ActorCalled() bool

ActorCalled returns true if FakeContext.Actor was called

func (*FakeContext) ActorCalledN

func (f *FakeContext) ActorCalledN(n int) bool

ActorCalledN returns true if FakeContext.Actor was called at least n times

func (*FakeContext) ActorCalledOnce

func (f *FakeContext) ActorCalledOnce() bool

ActorCalledOnce returns true if FakeContext.Actor was called exactly once

func (*FakeContext) ActorNotCalled

func (f *FakeContext) ActorNotCalled() bool

ActorNotCalled returns true if FakeContext.Actor was not called

func (*FakeContext) AssertActorCalled

func (f *FakeContext) AssertActorCalled(t *testing.T)

AssertActorCalled calls t.Error if FakeContext.Actor was not called

func (*FakeContext) AssertActorCalledN

func (f *FakeContext) AssertActorCalledN(t *testing.T, n int)

AssertActorCalledN calls t.Error if FakeContext.Actor was called less than n times

func (*FakeContext) AssertActorCalledOnce

func (f *FakeContext) AssertActorCalledOnce(t *testing.T)

AssertActorCalledOnce calls t.Error if FakeContext.Actor was not called exactly once

func (*FakeContext) AssertActorNotCalled

func (f *FakeContext) AssertActorNotCalled(t *testing.T)

AssertActorNotCalled calls t.Error if FakeContext.Actor was called

func (*FakeContext) AssertDeadlineCalled

func (f *FakeContext) AssertDeadlineCalled(t *testing.T)

AssertDeadlineCalled calls t.Error if FakeContext.Deadline was not called

func (*FakeContext) AssertDeadlineCalledN

func (f *FakeContext) AssertDeadlineCalledN(t *testing.T, n int)

AssertDeadlineCalledN calls t.Error if FakeContext.Deadline was called less than n times

func (*FakeContext) AssertDeadlineCalledOnce

func (f *FakeContext) AssertDeadlineCalledOnce(t *testing.T)

AssertDeadlineCalledOnce calls t.Error if FakeContext.Deadline was not called exactly once

func (*FakeContext) AssertDeadlineNotCalled

func (f *FakeContext) AssertDeadlineNotCalled(t *testing.T)

AssertDeadlineNotCalled calls t.Error if FakeContext.Deadline was called

func (*FakeContext) AssertDoneCalled

func (f *FakeContext) AssertDoneCalled(t *testing.T)

AssertDoneCalled calls t.Error if FakeContext.Done was not called

func (*FakeContext) AssertDoneCalledN

func (f *FakeContext) AssertDoneCalledN(t *testing.T, n int)

AssertDoneCalledN calls t.Error if FakeContext.Done was called less than n times

func (*FakeContext) AssertDoneCalledOnce

func (f *FakeContext) AssertDoneCalledOnce(t *testing.T)

AssertDoneCalledOnce calls t.Error if FakeContext.Done was not called exactly once

func (*FakeContext) AssertDoneNotCalled

func (f *FakeContext) AssertDoneNotCalled(t *testing.T)

AssertDoneNotCalled calls t.Error if FakeContext.Done was called

func (*FakeContext) AssertErrCalled

func (f *FakeContext) AssertErrCalled(t *testing.T)

AssertErrCalled calls t.Error if FakeContext.Err was not called

func (*FakeContext) AssertErrCalledN

func (f *FakeContext) AssertErrCalledN(t *testing.T, n int)

AssertErrCalledN calls t.Error if FakeContext.Err was called less than n times

func (*FakeContext) AssertErrCalledOnce

func (f *FakeContext) AssertErrCalledOnce(t *testing.T)

AssertErrCalledOnce calls t.Error if FakeContext.Err was not called exactly once

func (*FakeContext) AssertErrNotCalled

func (f *FakeContext) AssertErrNotCalled(t *testing.T)

AssertErrNotCalled calls t.Error if FakeContext.Err was called

func (*FakeContext) AssertRequestIDCalled

func (f *FakeContext) AssertRequestIDCalled(t *testing.T)

AssertRequestIDCalled calls t.Error if FakeContext.RequestID was not called

func (*FakeContext) AssertRequestIDCalledN

func (f *FakeContext) AssertRequestIDCalledN(t *testing.T, n int)

AssertRequestIDCalledN calls t.Error if FakeContext.RequestID was called less than n times

func (*FakeContext) AssertRequestIDCalledOnce

func (f *FakeContext) AssertRequestIDCalledOnce(t *testing.T)

AssertRequestIDCalledOnce calls t.Error if FakeContext.RequestID was not called exactly once

func (*FakeContext) AssertRequestIDNotCalled

func (f *FakeContext) AssertRequestIDNotCalled(t *testing.T)

AssertRequestIDNotCalled calls t.Error if FakeContext.RequestID was called

func (*FakeContext) AssertSetActorCalled

func (f *FakeContext) AssertSetActorCalled(t *testing.T)

AssertSetActorCalled calls t.Error if FakeContext.SetActor was not called

func (*FakeContext) AssertSetActorCalledN

func (f *FakeContext) AssertSetActorCalledN(t *testing.T, n int)

AssertSetActorCalledN calls t.Error if FakeContext.SetActor was called less than n times

func (*FakeContext) AssertSetActorCalledOnce

func (f *FakeContext) AssertSetActorCalledOnce(t *testing.T)

AssertSetActorCalledOnce calls t.Error if FakeContext.SetActor was not called exactly once

func (*FakeContext) AssertSetActorCalledOnceWith

func (_f21 *FakeContext) AssertSetActorCalledOnceWith(t *testing.T, v models.User)

AssertSetActorCalledOnceWith calls t.Error if FakeContext.SetActor was not called exactly once with the given values

func (*FakeContext) AssertSetActorCalledWith

func (_f19 *FakeContext) AssertSetActorCalledWith(t *testing.T, v models.User)

AssertSetActorCalledWith calls t.Error if FakeContext.SetActor was not called with the given values

func (*FakeContext) AssertSetActorNotCalled

func (f *FakeContext) AssertSetActorNotCalled(t *testing.T)

AssertSetActorNotCalled calls t.Error if FakeContext.SetActor was called

func (*FakeContext) AssertSetRequestIDCalled

func (f *FakeContext) AssertSetRequestIDCalled(t *testing.T)

AssertSetRequestIDCalled calls t.Error if FakeContext.SetRequestID was not called

func (*FakeContext) AssertSetRequestIDCalledN

func (f *FakeContext) AssertSetRequestIDCalledN(t *testing.T, n int)

AssertSetRequestIDCalledN calls t.Error if FakeContext.SetRequestID was called less than n times

func (*FakeContext) AssertSetRequestIDCalledOnce

func (f *FakeContext) AssertSetRequestIDCalledOnce(t *testing.T)

AssertSetRequestIDCalledOnce calls t.Error if FakeContext.SetRequestID was not called exactly once

func (*FakeContext) AssertSetRequestIDCalledOnceWith

func (_f15 *FakeContext) AssertSetRequestIDCalledOnceWith(t *testing.T, v string)

AssertSetRequestIDCalledOnceWith calls t.Error if FakeContext.SetRequestID was not called exactly once with the given values

func (*FakeContext) AssertSetRequestIDCalledWith

func (_f13 *FakeContext) AssertSetRequestIDCalledWith(t *testing.T, v string)

AssertSetRequestIDCalledWith calls t.Error if FakeContext.SetRequestID was not called with the given values

func (*FakeContext) AssertSetRequestIDNotCalled

func (f *FakeContext) AssertSetRequestIDNotCalled(t *testing.T)

AssertSetRequestIDNotCalled calls t.Error if FakeContext.SetRequestID was called

func (*FakeContext) AssertValueCalled

func (f *FakeContext) AssertValueCalled(t *testing.T)

AssertValueCalled calls t.Error if FakeContext.Value was not called

func (*FakeContext) AssertValueCalledN

func (f *FakeContext) AssertValueCalledN(t *testing.T, n int)

AssertValueCalledN calls t.Error if FakeContext.Value was called less than n times

func (*FakeContext) AssertValueCalledOnce

func (f *FakeContext) AssertValueCalledOnce(t *testing.T)

AssertValueCalledOnce calls t.Error if FakeContext.Value was not called exactly once

func (*FakeContext) AssertValueCalledOnceWith

func (_f8 *FakeContext) AssertValueCalledOnceWith(t *testing.T, key interface{})

AssertValueCalledOnceWith calls t.Error if FakeContext.Value was not called exactly once with the given values

func (*FakeContext) AssertValueCalledWith

func (_f6 *FakeContext) AssertValueCalledWith(t *testing.T, key interface{})

AssertValueCalledWith calls t.Error if FakeContext.Value was not called with the given values

func (*FakeContext) AssertValueNotCalled

func (f *FakeContext) AssertValueNotCalled(t *testing.T)

AssertValueNotCalled calls t.Error if FakeContext.Value was called

func (*FakeContext) Deadline

func (_f1 *FakeContext) Deadline() (deadline time.Time, ok bool)

func (*FakeContext) DeadlineCalled

func (f *FakeContext) DeadlineCalled() bool

DeadlineCalled returns true if FakeContext.Deadline was called

func (*FakeContext) DeadlineCalledN

func (f *FakeContext) DeadlineCalledN(n int) bool

DeadlineCalledN returns true if FakeContext.Deadline was called at least n times

func (*FakeContext) DeadlineCalledOnce

func (f *FakeContext) DeadlineCalledOnce() bool

DeadlineCalledOnce returns true if FakeContext.Deadline was called exactly once

func (*FakeContext) DeadlineNotCalled

func (f *FakeContext) DeadlineNotCalled() bool

DeadlineNotCalled returns true if FakeContext.Deadline was not called

func (*FakeContext) Done

func (_f2 *FakeContext) Done() (ident1 <-chan struct{})

func (*FakeContext) DoneCalled

func (f *FakeContext) DoneCalled() bool

DoneCalled returns true if FakeContext.Done was called

func (*FakeContext) DoneCalledN

func (f *FakeContext) DoneCalledN(n int) bool

DoneCalledN returns true if FakeContext.Done was called at least n times

func (*FakeContext) DoneCalledOnce

func (f *FakeContext) DoneCalledOnce() bool

DoneCalledOnce returns true if FakeContext.Done was called exactly once

func (*FakeContext) DoneNotCalled

func (f *FakeContext) DoneNotCalled() bool

DoneNotCalled returns true if FakeContext.Done was not called

func (*FakeContext) Err

func (_f3 *FakeContext) Err() (ident2 error)

func (*FakeContext) ErrCalled

func (f *FakeContext) ErrCalled() bool

ErrCalled returns true if FakeContext.Err was called

func (*FakeContext) ErrCalledN

func (f *FakeContext) ErrCalledN(n int) bool

ErrCalledN returns true if FakeContext.Err was called at least n times

func (*FakeContext) ErrCalledOnce

func (f *FakeContext) ErrCalledOnce() bool

ErrCalledOnce returns true if FakeContext.Err was called exactly once

func (*FakeContext) ErrNotCalled

func (f *FakeContext) ErrNotCalled() bool

ErrNotCalled returns true if FakeContext.Err was not called

func (*FakeContext) RequestID

func (_f10 *FakeContext) RequestID() (ident6 string)

func (*FakeContext) RequestIDCalled

func (f *FakeContext) RequestIDCalled() bool

RequestIDCalled returns true if FakeContext.RequestID was called

func (*FakeContext) RequestIDCalledN

func (f *FakeContext) RequestIDCalledN(n int) bool

RequestIDCalledN returns true if FakeContext.RequestID was called at least n times

func (*FakeContext) RequestIDCalledOnce

func (f *FakeContext) RequestIDCalledOnce() bool

RequestIDCalledOnce returns true if FakeContext.RequestID was called exactly once

func (*FakeContext) RequestIDNotCalled

func (f *FakeContext) RequestIDNotCalled() bool

RequestIDNotCalled returns true if FakeContext.RequestID was not called

func (*FakeContext) SetActor

func (_f17 *FakeContext) SetActor(v models.User)

func (*FakeContext) SetActorCalled

func (f *FakeContext) SetActorCalled() bool

SetActorCalled returns true if FakeContext.SetActor was called

func (*FakeContext) SetActorCalledN

func (f *FakeContext) SetActorCalledN(n int) bool

SetActorCalledN returns true if FakeContext.SetActor was called at least n times

func (*FakeContext) SetActorCalledOnce

func (f *FakeContext) SetActorCalledOnce() bool

SetActorCalledOnce returns true if FakeContext.SetActor was called exactly once

func (*FakeContext) SetActorCalledOnceWith

func (_f20 *FakeContext) SetActorCalledOnceWith(v models.User) bool

SetActorCalledOnceWith returns true if FakeContext.SetActor was called exactly once with the given values

func (*FakeContext) SetActorCalledWith

func (_f18 *FakeContext) SetActorCalledWith(v models.User) (found bool)

SetActorCalledWith returns true if FakeContext.SetActor was called with the given values

func (*FakeContext) SetActorNotCalled

func (f *FakeContext) SetActorNotCalled() bool

SetActorNotCalled returns true if FakeContext.SetActor was not called

func (*FakeContext) SetRequestID

func (_f11 *FakeContext) SetRequestID(v string)

func (*FakeContext) SetRequestIDCalled

func (f *FakeContext) SetRequestIDCalled() bool

SetRequestIDCalled returns true if FakeContext.SetRequestID was called

func (*FakeContext) SetRequestIDCalledN

func (f *FakeContext) SetRequestIDCalledN(n int) bool

SetRequestIDCalledN returns true if FakeContext.SetRequestID was called at least n times

func (*FakeContext) SetRequestIDCalledOnce

func (f *FakeContext) SetRequestIDCalledOnce() bool

SetRequestIDCalledOnce returns true if FakeContext.SetRequestID was called exactly once

func (*FakeContext) SetRequestIDCalledOnceWith

func (_f14 *FakeContext) SetRequestIDCalledOnceWith(v string) bool

SetRequestIDCalledOnceWith returns true if FakeContext.SetRequestID was called exactly once with the given values

func (*FakeContext) SetRequestIDCalledWith

func (_f12 *FakeContext) SetRequestIDCalledWith(v string) (found bool)

SetRequestIDCalledWith returns true if FakeContext.SetRequestID was called with the given values

func (*FakeContext) SetRequestIDNotCalled

func (f *FakeContext) SetRequestIDNotCalled() bool

SetRequestIDNotCalled returns true if FakeContext.SetRequestID was not called

func (*FakeContext) Value

func (_f4 *FakeContext) Value(key interface{}) (ident3 interface{})

func (*FakeContext) ValueCalled

func (f *FakeContext) ValueCalled() bool

ValueCalled returns true if FakeContext.Value was called

func (*FakeContext) ValueCalledN

func (f *FakeContext) ValueCalledN(n int) bool

ValueCalledN returns true if FakeContext.Value was called at least n times

func (*FakeContext) ValueCalledOnce

func (f *FakeContext) ValueCalledOnce() bool

ValueCalledOnce returns true if FakeContext.Value was called exactly once

func (*FakeContext) ValueCalledOnceWith

func (_f7 *FakeContext) ValueCalledOnceWith(key interface{}) bool

ValueCalledOnceWith returns true if FakeContext.Value was called exactly once with the given values

func (*FakeContext) ValueCalledWith

func (_f5 *FakeContext) ValueCalledWith(key interface{}) (found bool)

ValueCalledWith returns true if FakeContext.Value was called with the given values

func (*FakeContext) ValueNotCalled

func (f *FakeContext) ValueNotCalled() bool

ValueNotCalled returns true if FakeContext.Value was not called

func (*FakeContext) ValueResultsForCall

func (_f9 *FakeContext) ValueResultsForCall(key interface{}) (ident3 interface{}, found bool)

ValueResultsForCall returns the result values for the first call to FakeContext.Value with the given values

type RequestIDInvocation

type RequestIDInvocation struct {
	Results struct {
		Ident6 string
	}
}

RequestIDInvocation represents a single call of FakeContext.RequestID

type SetActorInvocation

type SetActorInvocation struct {
	Parameters struct {
		V models.User
	}
}

SetActorInvocation represents a single call of FakeContext.SetActor

type SetRequestIDInvocation

type SetRequestIDInvocation struct {
	Parameters struct {
		V string
	}
}

SetRequestIDInvocation represents a single call of FakeContext.SetRequestID

type ValueInvocation

type ValueInvocation struct {
	Parameters struct {
		Key interface{}
	}
	Results struct {
		Ident3 interface{}
	}
}

ValueInvocation represents a single call of FakeContext.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL