navidrome/plugins/pdk/go/host/nd_host_matcher_stub.go
Deluan Quintão 5a5311a9c0
fix(plugins): make generated mock stubs nil-safe for nilable returns (#5909)
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.
2026-08-08 21:57:44 -04:00

49 lines
1.7 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/navidrome/navidrome/plugins/pdk/go/types"
"github.com/stretchr/testify/mock"
)
// MatchOptions represents the MatchOptions data structure.
// MatchOptions carries optional parameters for a match request.
type MatchOptions struct {
Username string `json:"username"`
}
// mockMatcherService is the mock implementation for testing.
type mockMatcherService struct {
mock.Mock
}
// MatcherMock is the auto-instantiated mock instance for testing.
// Use this to set expectations: host.MatcherMock.On("MethodName", args...).Return(values...)
var MatcherMock = &mockMatcherService{}
// MatchSongs is the mock method for MatcherMatchSongs.
func (m *mockMatcherService) MatchSongs(songs []types.SongRef, opts MatchOptions) ([]*types.Track, error) {
args := m.Called(songs, opts)
var r0 []*types.Track
if v := args.Get(0); v != nil {
r0 = v.([]*types.Track)
}
return r0, args.Error(1)
}
// MatcherMatchSongs delegates to the mock instance.
// MatchSongs resolves each input song to its best-matching library track.
// It returns one entry per input song, in the same order as the input; the
// entry for an input song that had no match is empty (absent). Results are
// limited to the libraries the plugin (and the scoped user, if any) can access.
func MatcherMatchSongs(songs []types.SongRef, opts MatchOptions) ([]*types.Track, error) {
return MatcherMock.MatchSongs(songs, opts)
}