mock

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	*Plugin
	// Returned by Username
	Name string
	// Returned by Messages
	MessageChan chan bot.Message
	// Called by Send
	SendFunc func(bot.Message) error
	// Called by Reply
	ReplyFunc func(bot.Message) error
	// Called by Direct
	DirectFunc func(bot.Message) error
	// Called by Topic
	TopicFunc func(bot.Message) error
}

Chat is a mock bot.Chat

func NewChat

func NewChat() *Chat

NewChat returns a NOOP Chat

func (*Chat) Direct

func (a *Chat) Direct(m bot.Message) error

Direct delegates to Chat.DirectFunc

func (*Chat) Messages

func (a *Chat) Messages() <-chan bot.Message

Messages returns Chat.MessageChan

func (*Chat) Reply

func (a *Chat) Reply(m bot.Message) error

Reply delegates to Chat.ReplyFunc

func (*Chat) Send

func (a *Chat) Send(m bot.Message) error

Send delegates to Chat.SendFunc

func (*Chat) Topic

func (a *Chat) Topic(m bot.Message) error

Topic delegates to Chat.TopicFunc

func (*Chat) Username

func (a *Chat) Username() string

Username returns Chat.Name

type Level

type Level int

Level is the log level

const (
	// DebugLevel is the debug level
	DebugLevel Level = iota
	// InfoLevel is the info level
	InfoLevel
	// WarnLevel is the warn level
	WarnLevel
	// ErrorLevel is the error level
	ErrorLevel
	// FatalLevel is the fatal level
	FatalLevel
	// PanicLevel is the panic level
	PanicLevel
)

type Logger

type Logger struct {
	// WriteFunc intercepts non-formatted logs
	WriteFunc func(Level, ...interface{})
	// WritefFunc intercepts formatted logs
	WritefFunc func(Level, string, ...interface{})
}

Logger is a mock logger

func NewLogger

func NewLogger() *Logger

NewLogger creates a mock logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

Debug logs at DebugLevel

func (*Logger) Debugf

func (l *Logger) Debugf(fmt string, v ...interface{})

Debugf logs at DebugLevel with formatting

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error logs at ErrorLevel

func (*Logger) Errorf

func (l *Logger) Errorf(fmt string, v ...interface{})

Errorf logs at ErrorLevel with formatting

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

Fatal logs at FatalLevel

func (*Logger) Fatalf

func (l *Logger) Fatalf(fmt string, v ...interface{})

Fatalf logs at FatalLevel with formatting

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

Info logs at InfoLevel

func (*Logger) Infof

func (l *Logger) Infof(fmt string, v ...interface{})

Infof logs at InfoLevel with formatting

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

Panic logs at PanicLevel

func (*Logger) Panicf

func (l *Logger) Panicf(fmt string, v ...interface{})

Panicf logs at PanicLevel with formatting

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

Warn logs at WarnLevel

func (*Logger) Warnf

func (l *Logger) Warnf(fmt string, v ...interface{})

Warnf logs at WarnLevel with formatting

type Plugin

type Plugin struct {
	// Called by Load
	LoadFunc func(r *bot.Robot)
	// Called by Unload
	UnloadFunc func(r *bot.Robot)
}

Plugin is a mock bot.Plugin

func NewPlugin

func NewPlugin() *Plugin

NewPlugin returns a NOOP Plugin

func (*Plugin) Load

func (p *Plugin) Load(r *bot.Robot)

Load delegates to Plugin.LoadFunc

func (*Plugin) Unload

func (p *Plugin) Unload(r *bot.Robot)

Unload delegates to Plugin.UnloadFunc

type Store

type Store struct {
	// Called by Get
	GetFunc func(string, interface{}) error
	// Called by Set
	SetFunc func(string, interface{}) error
	// Called by Delete
	DeleteFunc func(string) error
}

Store is a mock bot.Store

func NewStore

func NewStore() *Store

NewStore returns a NOOP Store

func (Store) Delete

func (s Store) Delete(k string) error

Delete delegates to Chat.DeleteFunc

func (Store) Get

func (s Store) Get(k string, i interface{}) error

Get delegates to Chat.GetFunc

func (Store) Set

func (s Store) Set(k string, i interface{}) error

Set delegates to Chat.SetFunc

Jump to

Keyboard shortcuts

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