steammocks

package
v0.0.0-...-fb49ba0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMock

type APIMock struct {
	// GetOwnedGamesFunc mocks the GetOwnedGames method.
	GetOwnedGamesFunc func(ctx context.Context, id string) ([]*steam.Game, error)

	// GetPlayerSummaryFunc mocks the GetPlayerSummary method.
	GetPlayerSummaryFunc func(ctx context.Context, id string) (*steam.Summary, error)
	// contains filtered or unexported fields
}

APIMock is a mock implementation of steam.API.

func TestSomethingThatUsesAPI(t *testing.T) {

	// make and configure a mocked steam.API
	mockedAPI := &APIMock{
		GetOwnedGamesFunc: func(ctx context.Context, id string) ([]*steam.Game, error) {
			panic("mock out the GetOwnedGames method")
		},
		GetPlayerSummaryFunc: func(ctx context.Context, id string) (*steam.Summary, error) {
			panic("mock out the GetPlayerSummary method")
		},
	}

	// use mockedAPI in code that requires steam.API
	// and then make assertions.

}

func (*APIMock) GetOwnedGames

func (mock *APIMock) GetOwnedGames(ctx context.Context, id string) ([]*steam.Game, error)

GetOwnedGames calls GetOwnedGamesFunc.

func (*APIMock) GetOwnedGamesCalls

func (mock *APIMock) GetOwnedGamesCalls() []struct {
	Ctx context.Context
	ID  string
}

GetOwnedGamesCalls gets all the calls that were made to GetOwnedGames. Check the length with:

len(mockedAPI.GetOwnedGamesCalls())

func (*APIMock) GetPlayerSummary

func (mock *APIMock) GetPlayerSummary(ctx context.Context, id string) (*steam.Summary, error)

GetPlayerSummary calls GetPlayerSummaryFunc.

func (*APIMock) GetPlayerSummaryCalls

func (mock *APIMock) GetPlayerSummaryCalls() []struct {
	Ctx context.Context
	ID  string
}

GetPlayerSummaryCalls gets all the calls that were made to GetPlayerSummary. Check the length with:

len(mockedAPI.GetPlayerSummaryCalls())

Jump to

Keyboard shortcuts

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