Documentation ¶
Index ¶
- Constants
- Variables
- func Alerter(duration time.Duration, amount int, to io.Writer)
- func AssertContentType(t *testing.T, response *httptest.ResponseRecorder, want string)
- func AssertError(t *testing.T, got, want error)
- func AssertFinishCalledWith(t *testing.T, gameSpy *GameSpy, want string)
- func AssertGameStartedWith(t *testing.T, gameSpy *GameSpy, want int)
- func AssertLeague(t *testing.T, got, want League)
- func AssertMessagesSentToUser(t *testing.T, stdout *bytes.Buffer, messages ...string)
- func AssertNoError(t *testing.T, got error)
- func AssertPlayerWin(t *testing.T, store *StubPlayerStore, winner string)
- func AssertResponseBody(t *testing.T, got, want string)
- func AssertScheduledAlert(t *testing.T, got, want ScheduledAlert)
- func AssertScoreEquals(t *testing.T, got, want int)
- func AssertStatus(t *testing.T, got, want int)
- func CheckSchedulingCases(cases []ScheduledAlert, t *testing.T, blindAlerter *SpyBlindAlerter)
- func CreateTempFile(t *testing.T, initialData string) (io.ReadWriteSeeker, func())
- func MustDialWS(t *testing.T, url string) *websocket.Conn
- func NewGameRequest() *http.Request
- func NewGetScoreRequest(name string) *http.Request
- func NewLeagueRequest() *http.Request
- func NewPostWinRequest(name string) *http.Request
- func WriteWSMessage(t *testing.T, conn *websocket.Conn, message string)
- type BlindAlerter
- type BlindAlerterFunc
- type CLI
- type Game
- type GameSpy
- type League
- type Player
- type PlayerServer
- type PlayerStore
- type PostgreSQLPlayerStore
- type ScheduledAlert
- type SpyBlindAlerter
- type StubPlayerStore
- type TexasHoldem
Constants ¶
View Source
const BadPlayerInputErrMsg = "Bad value received for number of players, please try again with a number"
View Source
const JsonContentType = "application/json"
View Source
const PlayerPrompt = "Please enter the number of players: "
Variables ¶
View Source
var DummyGame = &GameSpy{}
View Source
var ErrRecordAlreadyExists = errors.New("already exists")
Functions ¶
func AssertContentType ¶
func AssertContentType(t *testing.T, response *httptest.ResponseRecorder, want string)
func AssertError ¶
func AssertFinishCalledWith ¶
func AssertLeague ¶
func AssertNoError ¶
func AssertPlayerWin ¶
func AssertPlayerWin(t *testing.T, store *StubPlayerStore, winner string)
func AssertResponseBody ¶
func AssertScheduledAlert ¶
func AssertScheduledAlert(t *testing.T, got, want ScheduledAlert)
func AssertScoreEquals ¶
func AssertStatus ¶
func CheckSchedulingCases ¶
func CheckSchedulingCases(cases []ScheduledAlert, t *testing.T, blindAlerter *SpyBlindAlerter)
func CreateTempFile ¶
func CreateTempFile(t *testing.T, initialData string) (io.ReadWriteSeeker, func())
func NewGameRequest ¶
func NewGetScoreRequest ¶
func NewLeagueRequest ¶
func NewPostWinRequest ¶
Types ¶
type BlindAlerter ¶
type BlindAlerterFunc ¶
func (BlindAlerterFunc) ScheduleAlertAt ¶
type Player ¶
type Player struct { ID int `sql:"column:id;" json:"id"` Name string `sql:"column:name;" json:"name"` Wins int `sql:"columns:wins;" json:"wins"` }
Player struct to hold base data
type PlayerServer ¶
func MustMakePlayerServer ¶
func MustMakePlayerServer(t *testing.T, store PlayerStore, spy *GameSpy) *PlayerServer
func NewPlayerServer ¶
func NewPlayerServer(store PlayerStore, game Game) (*PlayerServer, error)
type PlayerStore ¶
type PlayerStore interface { GetPlayerScore(name string) int RecordWin(name string) GetLeague() League }
PlayerStore interface
type PostgreSQLPlayerStore ¶
PostgreSQLPlayerStore
func NewPostgreSQLPlayerStore ¶
func NewPostgreSQLPlayerStore(host, port, user, dbname, pass string) (*PostgreSQLPlayerStore, func())
func (*PostgreSQLPlayerStore) GetLeague ¶
func (s *PostgreSQLPlayerStore) GetLeague() League
func (*PostgreSQLPlayerStore) GetPlayerScore ¶
func (s *PostgreSQLPlayerStore) GetPlayerScore(name string) int
func (*PostgreSQLPlayerStore) RecordWin ¶
func (s *PostgreSQLPlayerStore) RecordWin(name string)
type ScheduledAlert ¶
func (ScheduledAlert) String ¶
func (s ScheduledAlert) String() string
type SpyBlindAlerter ¶
type SpyBlindAlerter struct {
Alerts []ScheduledAlert
}
func (*SpyBlindAlerter) ScheduleAlertAt ¶
type StubPlayerStore ¶
func NewStubPlayerStore ¶
func NewStubPlayerStore( initialData map[string]int, initialWinCalls []string, initialLeague League, ) *StubPlayerStore
func (*StubPlayerStore) GetLeague ¶
func (s *StubPlayerStore) GetLeague() League
func (*StubPlayerStore) GetPlayerScore ¶
func (s *StubPlayerStore) GetPlayerScore(name string) int
func (*StubPlayerStore) RecordWin ¶
func (s *StubPlayerStore) RecordWin(name string)
type TexasHoldem ¶
type TexasHoldem struct { Alerter BlindAlerter Store PlayerStore }
func NewTexasHoldem ¶
func NewTexasHoldem(alerter BlindAlerter, store PlayerStore) *TexasHoldem
func (*TexasHoldem) Finish ¶
func (p *TexasHoldem) Finish(winner string)
func (*TexasHoldem) Start ¶
func (p *TexasHoldem) Start(numberOfPlayers int)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.