Skip to content

Commit

Permalink
games_test.go: properly fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DjMike238 committed Jun 9, 2021
1 parent 6464c43 commit 1e523c0
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions games_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ package echotron

import "testing"

var gameMsgTmp *Message
var (
gameMsgTmp *Message
highScores []GameHighScore
)

func TestSendGame(t *testing.T) {
resp, err := api.SendGame(
Expand All @@ -40,14 +43,10 @@ func TestSendGame(t *testing.T) {
gameMsgTmp = resp.Result
}

func TestSetGameScore(t *testing.T) {
resp, err := api.SetGameScore(
func TestGameHighScores(t *testing.T) {
resp, err := api.GetGameHighScores(
chatID,
545,
NewMessageID(chatID, gameMsgTmp.ID),
&GameScoreOptions{
Force: true,
},
)

if err != nil {
Expand All @@ -57,12 +56,24 @@ func TestSetGameScore(t *testing.T) {
if !resp.Ok {
t.Fatalf("%d %s", resp.ErrorCode, resp.Description)
}

highScores = resp.Result
}

func TestGameHighScores(t *testing.T) {
resp, err := api.GetGameHighScores(
func TestSetGameScore(t *testing.T) {
var score int

if len(highScores) > 0 {
score = highScores[0].Score + 1
}

resp, err := api.SetGameScore(
chatID,
score,
NewMessageID(chatID, gameMsgTmp.ID),
&GameScoreOptions{
Force: true,
},
)

if err != nil {
Expand Down

0 comments on commit 1e523c0

Please sign in to comment.