Skip to content

Commit

Permalink
Merge pull request #1 from dimuska139/get-game-fix
Browse files Browse the repository at this point in the history
GetGame fix
  • Loading branch information
dimuska139 authored May 27, 2022
2 parents fa07df5 05bbd0a commit d1c94e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions game_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 2,21 @@ package rawg

import "context"

func (suite *RAWGTestSuite) TestGetGame() {
game, err := suite.client.GetGame(context.Background(), 1)
func (suite *RAWGTestSuite) TestGetGameById() {
game, err := suite.client.GetGame(context.Background(), "1")
suite.NoError(err)
suite.Equal("D/Generation HD", game.Name)
}

func (suite *RAWGTestSuite) TestGetGameBySlug() {
game, err := suite.client.GetGame(context.Background(), "vampire-the-masquerade-bloodlines-2")
suite.NoError(err)
suite.Equal("Vampire: The Masquerade - Bloodlines 2", game.Name)
}

func (suite *RAWGTestSuite) TestGetGameFailed() {
suite.client.baseUrl = ""
game, err := suite.client.GetGame(context.Background(), 1)
game, err := suite.client.GetGame(context.Background(), "1")
suite.Error(err)
suite.Nil(game)
}
4 changes: 2 additions & 2 deletions game_twitch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 3,15 @@ package rawg
import "context"

func (suite *RAWGTestSuite) TestGetTwitchVideos() {
videos, total, err := suite.client.GetGameTwitch(context.Background(), 1)
videos, total, err := suite.client.GetGameTwitch(context.Background(), 10213)
suite.NoError(err)
suite.NotEqual(0, total)
suite.NotEqual(0, len(videos))
}

func (suite *RAWGTestSuite) TestGetTwitchFailed() {
suite.client.baseUrl = ""
videos, total, err := suite.client.GetGameTwitch(context.Background(), 1)
videos, total, err := suite.client.GetGameTwitch(context.Background(), 6256)
suite.Error(err)
suite.Equal(0, total)
suite.Equal(0, len(videos))
Expand Down
4 changes: 2 additions & 2 deletions games.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 151,8 @@ func (api *Client) GetGameStores(ctx context.Context, gameID int, page int, page
}

// GetGame returns details of the game
func (api *Client) GetGame(ctx context.Context, id int) (*GameDetailed, error) {
path := fmt.Sprintf("/games/%d", id)
func (api *Client) GetGame(ctx context.Context, idOrSlug string) (*GameDetailed, error) {
path := fmt.Sprintf("/games/%s", idOrSlug)

var platform GameDetailed

Expand Down

0 comments on commit d1c94e4

Please sign in to comment.