mock

package
v0.0.0-...-466853b Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	TopicFn      func(name string) (lobby.Topic, error)
	TopicInvoked int

	CloseFn      func() error
	CloseInvoked int
}

Backend is a mock service that runs provided functions. Useful for testing.

func (*Backend) Close

func (s *Backend) Close() error

Close runs CloseFn and increments CloseInvoked when invoked.

func (*Backend) Topic

func (s *Backend) Topic(name string) (lobby.Topic, error)

Topic runs TopicFn and increments TopicInvoked when invoked.

type Plugin

type Plugin struct {
	sync.Mutex

	NameFn      func() string
	NameInvoked int

	CloseFn      func() error
	CloseInvoked int

	WaitFn      func() error
	WaitInvoked int
}

Plugin is a mock service that runs provided functions. Useful for testing.

func (*Plugin) Close

func (s *Plugin) Close() error

Close runs CloseFn and increments CloseInvoked when invoked.

func (*Plugin) Name

func (s *Plugin) Name() string

Name runs NameFn and increments NameInvoked when invoked.

func (*Plugin) Wait

func (s *Plugin) Wait() error

Wait runs WaitFn and increments WaitInvoked when invoked.

type Registry

type Registry struct {
	CreateFn      func(string, string) error
	CreateInvoked int

	TopicFn      func(string) (lobby.Topic, error)
	TopicInvoked int

	CloseFn      func() error
	CloseInvoked int

	Backends map[string]lobby.Backend
}

Registry is a mock service that runs provided functions. Useful for testing.

func (*Registry) Close

func (r *Registry) Close() error

Close runs CloseFn and increments CloseInvoked when invoked.

func (*Registry) Create

func (r *Registry) Create(backendName, topicName string) error

Create runs CreateFn and increments CreateInvoked when invoked.

func (*Registry) RegisterBackend

func (r *Registry) RegisterBackend(name string, backend lobby.Backend)

RegisterBackend saves the backend in the Backends map.

func (*Registry) Topic

func (r *Registry) Topic(name string) (lobby.Topic, error)

Topic runs TopicFn and increments TopicInvoked when invoked.

type Topic

type Topic struct {
	SendFn      func(*lobby.Message) error
	SendInvoked int

	CloseFn      func() error
	CloseInvoked int
}

Topic is a mock service that runs provided functions. Useful for testing.

func (*Topic) Close

func (b *Topic) Close() error

Close runs CloseFn and increments CloseInvoked when invoked.

func (*Topic) Send

func (b *Topic) Send(message *lobby.Message) error

Send runs SendFn and increments SendInvoked when invoked.

Jump to

Keyboard shortcuts

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