Skip to content

Instantly share code, notes, and snippets.

@ncomet
Last active May 2, 2022 12:48
Show Gist options
  • Save ncomet/e680c11cff996f84c10369cfd63e1605 to your computer and use it in GitHub Desktop.
Save ncomet/e680c11cff996f84c10369cfd63e1605 to your computer and use it in GitHub Desktop.
AllGames tests
...
func Test_Add(t *testing.T) {
gameId := domain.GameId(uuid.NewString())
allGames.Add(&domain.Game{
Id: gameId,
Title: "Assassin's Creed Valhalla",
PEGI: domain.Eighteen,
})
game := allGames.By(gameId)
assert.Equal(t, gameId, game.Id)
assert.Equal(t, "Assassin's Creed Valhalla", game.Title)
assert.Equal(t, domain.Eighteen, game.PEGI)
}
func Test_Replace(t *testing.T) {
gameId := domain.GameId(uuid.NewString())
allGames.Add(&domain.Game{
Id: gameId,
Title: "Rayman Raving Rabbids",
PEGI: domain.Seven,
})
allGames.Add(&domain.Game{
Id: gameId,
Title: "Rainbow Six Siege",
PEGI: domain.Eighteen,
})
game := allGames.By(gameId)
assert.Equal(t, gameId, game.Id)
assert.Equal(t, "Rainbow Six Siege", game.Title)
assert.Equal(t, domain.Eighteen, game.PEGI)
}
func Test_By(t *testing.T) {
gameId := domain.GameId(uuid.NewString())
allGames.Add(&domain.Game{
Id: gameId,
Title: "Just Dance 2022",
PEGI: domain.Three,
})
allGames.Add(&domain.Game{
Id: domain.GameId(uuid.NewString()),
Title: "Far Cry 6",
PEGI: domain.Eighteen,
})
game := allGames.By(gameId)
assert.Equal(t, gameId, game.Id)
assert.Equal(t, "Just Dance 2022", game.Title)
assert.Equal(t, domain.Three, game.PEGI)
}
func Test_All(t *testing.T) {
previous := len(allGames.All())
allGames.Add(&domain.Game{
Id: domain.GameId(uuid.NewString()),
Title: "Far Cry 6",
PEGI: domain.Eighteen,
})
assert.Equal(t, previous+1, len(allGames.All()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment