mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-18 07:30:29 +00:00
The ndpgen mock accessors asserted return types unconditionally, so a plugin test using Return(nil, ...) — the natural way to model an empty result or a pagination terminal page — panicked on the untyped-nil type assertion instead of returning the zero value. Guard pointer, slice, map and any returns in both the host-service client stubs and the PDK stub, and regenerate.
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
// Code generated by ndpgen. DO NOT EDIT.
|
|
//
|
|
// This file contains mock implementations for non-WASM builds.
|
|
// These mocks allow IDE support, compilation, and unit testing on non-WASM platforms.
|
|
// Plugin authors can use the exported mock instances to set expectations in tests.
|
|
//
|
|
//go:build !wasip1
|
|
|
|
package host
|
|
|
|
import (
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
// Library represents the Library data structure.
|
|
// Library represents a music library with metadata.
|
|
type Library struct {
|
|
ID int32 `json:"id"`
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
MountPoint string `json:"mountPoint"`
|
|
LastScanAt int64 `json:"lastScanAt"`
|
|
TotalSongs int32 `json:"totalSongs"`
|
|
TotalAlbums int32 `json:"totalAlbums"`
|
|
TotalArtists int32 `json:"totalArtists"`
|
|
TotalSize int64 `json:"totalSize"`
|
|
TotalDuration float64 `json:"totalDuration"`
|
|
}
|
|
|
|
// mockLibraryService is the mock implementation for testing.
|
|
type mockLibraryService struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// LibraryMock is the auto-instantiated mock instance for testing.
|
|
// Use this to set expectations: host.LibraryMock.On("MethodName", args...).Return(values...)
|
|
var LibraryMock = &mockLibraryService{}
|
|
|
|
// GetLibrary is the mock method for LibraryGetLibrary.
|
|
func (m *mockLibraryService) GetLibrary(id int32) (*Library, error) {
|
|
args := m.Called(id)
|
|
var r0 *Library
|
|
if v := args.Get(0); v != nil {
|
|
r0 = v.(*Library)
|
|
}
|
|
return r0, args.Error(1)
|
|
}
|
|
|
|
// LibraryGetLibrary delegates to the mock instance.
|
|
// GetLibrary retrieves metadata for a specific library by ID.
|
|
//
|
|
// Parameters:
|
|
// - id: The library's unique identifier
|
|
//
|
|
// Returns the library metadata, or an error if the library is not found.
|
|
func LibraryGetLibrary(id int32) (*Library, error) {
|
|
return LibraryMock.GetLibrary(id)
|
|
}
|
|
|
|
// GetAllLibraries is the mock method for LibraryGetAllLibraries.
|
|
func (m *mockLibraryService) GetAllLibraries() ([]Library, error) {
|
|
args := m.Called()
|
|
var r0 []Library
|
|
if v := args.Get(0); v != nil {
|
|
r0 = v.([]Library)
|
|
}
|
|
return r0, args.Error(1)
|
|
}
|
|
|
|
// LibraryGetAllLibraries delegates to the mock instance.
|
|
// GetAllLibraries retrieves metadata for all configured libraries.
|
|
//
|
|
// Returns a slice of all libraries with their metadata.
|
|
func LibraryGetAllLibraries() ([]Library, error) {
|
|
return LibraryMock.GetAllLibraries()
|
|
}
|