mock

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpResponse

type HttpResponse struct {
	StatusCode int
	// contains filtered or unexported fields
}

HttpResponse mock response, which should be used in tests

func NewMockContext

func NewMockContext(req *http.Request) (*beegoCtx.Context, *HttpResponse)

func NewMockHttpResponse

func NewMockHttpResponse() *HttpResponse

NewMockHttpResponse you should only use this in your test code

func (*HttpResponse) BodyToString

func (m *HttpResponse) BodyToString() string

BodyToString return the body as the string

func (*HttpResponse) Header

func (m *HttpResponse) Header() http.Header

Header return headers

func (*HttpResponse) JsonUnmarshal

func (m *HttpResponse) JsonUnmarshal(value interface{}) error

JsonUnmarshal convert the body to object

func (*HttpResponse) Reset

func (m *HttpResponse) Reset()

Reset will reset the status to init status Usually, you want to reuse this instance you may need to call Reset

func (*HttpResponse) Write

func (m *HttpResponse) Write(bytes []byte) (int, error)

Write append the body

func (*HttpResponse) WriteHeader

func (m *HttpResponse) WriteHeader(statusCode int)

WriteHeader set the status code

type SessionProvider

type SessionProvider struct {
	Store *SessionStore
}

SessionProvider will replace session provider with "mock" provider

func NewSessionProvider

func NewSessionProvider(name string) *SessionProvider

NewSessionProvider create new SessionProvider and you could use it to mock data Parameter "name" is the real SessionProvider you used

func (*SessionProvider) SessionAll

func (s *SessionProvider) SessionAll(ctx context.Context) int

SessionAll return 0

func (*SessionProvider) SessionDestroy

func (s *SessionProvider) SessionDestroy(ctx context.Context, sid string) error

SessionDestroy reset Store to nil

func (*SessionProvider) SessionExist

func (s *SessionProvider) SessionExist(ctx context.Context, sid string) (bool, error)

SessionExist always return true

func (*SessionProvider) SessionGC

func (s *SessionProvider) SessionGC(ctx context.Context)

SessionGC do nothing

func (*SessionProvider) SessionInit

func (s *SessionProvider) SessionInit(ctx context.Context, gclifetime int64, config string) error

SessionInit do nothing

func (*SessionProvider) SessionRead

func (s *SessionProvider) SessionRead(ctx context.Context, sid string) (session.Store, error)

SessionRead return Store

func (*SessionProvider) SessionRegenerate

func (s *SessionProvider) SessionRegenerate(ctx context.Context, oldsid, sid string) (session.Store, error)

SessionRegenerate create new Store

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

func (*SessionStore) Delete

func (s *SessionStore) Delete(ctx context.Context, key interface{}) error

func (*SessionStore) Flush

func (s *SessionStore) Flush(ctx context.Context) error

func (*SessionStore) Get

func (s *SessionStore) Get(ctx context.Context, key interface{}) interface{}

func (*SessionStore) SessionID

func (s *SessionStore) SessionID(ctx context.Context) string

func (*SessionStore) SessionRelease

func (s *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter)

SessionRelease do nothing

func (*SessionStore) Set

func (s *SessionStore) Set(ctx context.Context, key, value interface{}) error

Jump to

Keyboard shortcuts

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