apitest

package
v0.1.0-rc3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockDevices

type MockDevices struct {
	DevicesResult          []api.Device
	DevicesErr             error
	TransferErr            error
	TransferPlaybackCalled bool
}

MockDevices is a test double for DevicesAPI.

func (*MockDevices) Devices

func (m *MockDevices) Devices(_ context.Context) ([]api.Device, error)

Devices returns the configured result and error.

func (*MockDevices) TransferPlayback

func (m *MockDevices) TransferPlayback(_ context.Context, _ string, _ bool) error

TransferPlayback records the call and returns the configured error.

type MockLibrary

type MockLibrary struct {
	PlaylistsResult       []api.SimplePlaylist
	PlaylistsErr          error
	PlaylistTracksResult  []api.Track
	PlaylistTracksTotal   int
	PlaylistTracksHasNext bool
	PlaylistTracksErr     error
	AlbumTracksResult     []api.Track
	AlbumTracksHasNext    bool
	AlbumTracksErr        error
	SavedAlbumsResult     []api.SavedAlbum
	SavedAlbumsErr        error
	LikedTracksResult     []api.SavedTrack
	LikedTracksErr        error
	RecentlyPlayedResult  []api.PlayHistory
	RecentlyPlayedErr     error
	LikeErr               error
	UnlikeErr             error

	LikeTrackCalled   bool
	UnlikeTrackCalled bool
}

MockLibrary is a test double for LibraryAPI.

func (*MockLibrary) AlbumTracks

func (m *MockLibrary) AlbumTracks(_ context.Context, _ string, _, _ int) ([]api.Track, bool, error)

AlbumTracks returns the configured result, hasNext, and error.

func (*MockLibrary) GetPlaylist

func (m *MockLibrary) GetPlaylist(_ context.Context, _ string) ([]api.Track, int, bool, error)

GetPlaylist returns the configured result, total, hasNext, and error. Delegates to the same PlaylistTracks fields for simplicity in tests.

func (*MockLibrary) LikeTrack

func (m *MockLibrary) LikeTrack(_ context.Context, _ string) error

LikeTrack records the call and returns the configured error.

func (*MockLibrary) LikedTracks

func (m *MockLibrary) LikedTracks(_ context.Context, _, _ int) ([]api.SavedTrack, error)

LikedTracks returns the configured result and error.

func (*MockLibrary) PlaylistTracks

func (m *MockLibrary) PlaylistTracks(_ context.Context, _ string, _, _ int) ([]api.Track, int, bool, error)

PlaylistTracks returns the configured result, total, hasNext, and error.

func (*MockLibrary) Playlists

func (m *MockLibrary) Playlists(_ context.Context, _, _ int) ([]api.SimplePlaylist, error)

Playlists returns the configured result and error.

func (*MockLibrary) RecentlyPlayed

func (m *MockLibrary) RecentlyPlayed(_ context.Context, _ int) ([]api.PlayHistory, error)

RecentlyPlayed returns the configured result and error.

func (*MockLibrary) SavedAlbums

func (m *MockLibrary) SavedAlbums(_ context.Context, _, _ int) ([]api.SavedAlbum, error)

SavedAlbums returns the configured result and error.

func (*MockLibrary) UnlikeTrack

func (m *MockLibrary) UnlikeTrack(_ context.Context, _ string) error

UnlikeTrack records the call and returns the configured error.

type MockPlayer

type MockPlayer struct {
	PlaybackStateResult *api.PlaybackState
	PlaybackStateErr    error
	PlayErr             error
	PauseErr            error
	NextErr             error
	PreviousErr         error
	SeekErr             error
	SetVolumeErr        error
	SetShuffleErr       error
	SetRepeatErr        error
	AddToQueueErr       error
	QueueResult         *api.QueueResponse
	QueueErr            error

	PlayCalled       bool
	PauseCalled      bool
	NextCalled       bool
	PreviousCalled   bool
	SeekCalled       bool
	SetVolumeCalled  bool
	SetShuffleCalled bool
	SetRepeatCalled  bool
	AddToQueueCalled bool
}

MockPlayer is a test double for PlayerAPI. Set the Result/Err fields before calling the method to control behavior. Called booleans record whether mutating methods were invoked.

func (*MockPlayer) AddToQueue

func (m *MockPlayer) AddToQueue(_ context.Context, _ string) error

AddToQueue records the call and returns the configured error.

func (*MockPlayer) Next

func (m *MockPlayer) Next(_ context.Context) error

Next records the call and returns the configured error.

func (*MockPlayer) Pause

func (m *MockPlayer) Pause(_ context.Context) error

Pause records the call and returns the configured error.

func (*MockPlayer) Play

Play records the call and returns the configured error.

func (*MockPlayer) PlaybackState

func (m *MockPlayer) PlaybackState(_ context.Context) (*api.PlaybackState, error)

PlaybackState returns the configured PlaybackStateResult and error.

func (*MockPlayer) Previous

func (m *MockPlayer) Previous(_ context.Context) error

Previous records the call and returns the configured error.

func (*MockPlayer) Queue

func (m *MockPlayer) Queue(_ context.Context) (*api.QueueResponse, error)

Queue returns the configured QueueResult and error.

func (*MockPlayer) Seek

func (m *MockPlayer) Seek(_ context.Context, _ int) error

Seek records the call and returns the configured error.

func (*MockPlayer) SetRepeat

func (m *MockPlayer) SetRepeat(_ context.Context, _ string) error

SetRepeat records the call and returns the configured error.

func (*MockPlayer) SetShuffle

func (m *MockPlayer) SetShuffle(_ context.Context, _ bool) error

SetShuffle records the call and returns the configured error.

func (*MockPlayer) SetVolume

func (m *MockPlayer) SetVolume(_ context.Context, _ int) error

SetVolume records the call and returns the configured error.

type MockPlaylists

type MockPlaylists struct {
	CreateResult         *api.SimplePlaylist
	CreateErr            error
	UpdateErr            error
	AddTracksErr         error
	RemoveTracksErr      error
	ReorderErr           error
	CreatePlaylistCalled bool
	UpdatePlaylistCalled bool
}

MockPlaylists is a test double for PlaylistsAPI.

func (*MockPlaylists) AddTracksToPlaylist

func (m *MockPlaylists) AddTracksToPlaylist(_ context.Context, _ string, _ []string) error

AddTracksToPlaylist returns the configured error.

func (*MockPlaylists) CreatePlaylist

func (m *MockPlaylists) CreatePlaylist(_ context.Context, _, _ string, _ bool) (*api.SimplePlaylist, error)

CreatePlaylist records the call and returns the configured result and error.

func (*MockPlaylists) RemoveTracksFromPlaylist

func (m *MockPlaylists) RemoveTracksFromPlaylist(_ context.Context, _ string, _ []string) error

RemoveTracksFromPlaylist returns the configured error.

func (*MockPlaylists) ReorderPlaylistTracks

func (m *MockPlaylists) ReorderPlaylistTracks(_ context.Context, _ string, _, _, _ int) error

ReorderPlaylistTracks returns the configured error.

func (*MockPlaylists) UpdatePlaylist

func (m *MockPlaylists) UpdatePlaylist(_ context.Context, _, _, _ string) error

UpdatePlaylist records the call and returns the configured error.

type MockSearch

type MockSearch struct {
	SearchResult *api.SearchResult
	SearchErr    error
}

MockSearch is a test double for SearchAPI.

func (*MockSearch) Search

func (m *MockSearch) Search(_ context.Context, _ string, _ []string, _, _ int) (*api.SearchResult, error)

Search returns the configured result and error.

type MockUser

type MockUser struct {
	ProfileResult        api.UserProfile
	ProfileErr           error
	TopTracksResult      []api.Track
	TopTracksErr         error
	TopArtistsResult     []api.FullArtist
	TopArtistsErr        error
	RecentlyPlayedResult []api.PlayHistory
	RecentlyPlayedErr    error
}

MockUser is a test double for UserAPI.

func (*MockUser) Profile

func (m *MockUser) Profile(_ context.Context) (api.UserProfile, error)

Profile returns the configured UserProfile and error.

func (*MockUser) RecentlyPlayed

func (m *MockUser) RecentlyPlayed(_ context.Context, _ int) ([]api.PlayHistory, error)

RecentlyPlayed returns the configured result and error.

func (*MockUser) TopArtists

func (m *MockUser) TopArtists(_ context.Context, _ string, _ int) ([]api.FullArtist, error)

TopArtists returns the configured result and error.

func (*MockUser) TopTracks

func (m *MockUser) TopTracks(_ context.Context, _ string, _ int) ([]api.Track, error)

TopTracks returns the configured result and error.

Jump to

Keyboard shortcuts

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