mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +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.
56 lines
1.9 KiB
Go
56 lines
1.9 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"
|
|
)
|
|
|
|
// mockSubsonicAPIService is the mock implementation for testing.
|
|
type mockSubsonicAPIService struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// SubsonicAPIMock is the auto-instantiated mock instance for testing.
|
|
// Use this to set expectations: host.SubsonicAPIMock.On("MethodName", args...).Return(values...)
|
|
var SubsonicAPIMock = &mockSubsonicAPIService{}
|
|
|
|
// Call is the mock method for SubsonicAPICall.
|
|
func (m *mockSubsonicAPIService) Call(uri string) (string, error) {
|
|
args := m.Called(uri)
|
|
return args.String(0), args.Error(1)
|
|
}
|
|
|
|
// SubsonicAPICall delegates to the mock instance.
|
|
// Call executes a Subsonic API request and returns the JSON response.
|
|
//
|
|
// The uri parameter should be the Subsonic API path without the server prefix,
|
|
// e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON.
|
|
func SubsonicAPICall(uri string) (string, error) {
|
|
return SubsonicAPIMock.Call(uri)
|
|
}
|
|
|
|
// CallRaw is the mock method for SubsonicAPICallRaw.
|
|
func (m *mockSubsonicAPIService) CallRaw(uri string) (string, []byte, error) {
|
|
args := m.Called(uri)
|
|
var r1 []byte
|
|
if v := args.Get(1); v != nil {
|
|
r1 = v.([]byte)
|
|
}
|
|
return args.String(0), r1, args.Error(2)
|
|
}
|
|
|
|
// SubsonicAPICallRaw delegates to the mock instance.
|
|
// CallRaw executes a Subsonic API request and returns the raw binary response.
|
|
// Designed for binary endpoints like getCoverArt and stream that return
|
|
// non-JSON data. The data is base64-encoded over JSON on the wire.
|
|
func SubsonicAPICallRaw(uri string) (string, []byte, error) {
|
|
return SubsonicAPIMock.CallRaw(uri)
|
|
}
|