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.
209 lines
6.6 KiB
Go
209 lines
6.6 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"
|
|
)
|
|
|
|
// mockCacheService is the mock implementation for testing.
|
|
type mockCacheService struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// CacheMock is the auto-instantiated mock instance for testing.
|
|
// Use this to set expectations: host.CacheMock.On("MethodName", args...).Return(values...)
|
|
var CacheMock = &mockCacheService{}
|
|
|
|
// SetString is the mock method for CacheSetString.
|
|
func (m *mockCacheService) SetString(key string, value string, ttlSeconds int64) error {
|
|
args := m.Called(key, value, ttlSeconds)
|
|
return args.Error(0)
|
|
}
|
|
|
|
// CacheSetString delegates to the mock instance.
|
|
// SetString stores a string value in the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
// - value: The string value to store
|
|
// - ttlSeconds: Time-to-live in seconds (0 uses default of 24 hours)
|
|
//
|
|
// Returns an error if the operation fails.
|
|
func CacheSetString(key string, value string, ttlSeconds int64) error {
|
|
return CacheMock.SetString(key, value, ttlSeconds)
|
|
}
|
|
|
|
// GetString is the mock method for CacheGetString.
|
|
func (m *mockCacheService) GetString(key string) (string, bool, error) {
|
|
args := m.Called(key)
|
|
return args.String(0), args.Bool(1), args.Error(2)
|
|
}
|
|
|
|
// CacheGetString delegates to the mock instance.
|
|
// GetString retrieves a string value from the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns the value and whether the key exists. If the key doesn't exist
|
|
// or the stored value is not a string, exists will be false.
|
|
func CacheGetString(key string) (string, bool, error) {
|
|
return CacheMock.GetString(key)
|
|
}
|
|
|
|
// SetInt is the mock method for CacheSetInt.
|
|
func (m *mockCacheService) SetInt(key string, value int64, ttlSeconds int64) error {
|
|
args := m.Called(key, value, ttlSeconds)
|
|
return args.Error(0)
|
|
}
|
|
|
|
// CacheSetInt delegates to the mock instance.
|
|
// SetInt stores an integer value in the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
// - value: The integer value to store
|
|
// - ttlSeconds: Time-to-live in seconds (0 uses default of 24 hours)
|
|
//
|
|
// Returns an error if the operation fails.
|
|
func CacheSetInt(key string, value int64, ttlSeconds int64) error {
|
|
return CacheMock.SetInt(key, value, ttlSeconds)
|
|
}
|
|
|
|
// GetInt is the mock method for CacheGetInt.
|
|
func (m *mockCacheService) GetInt(key string) (int64, bool, error) {
|
|
args := m.Called(key)
|
|
return args.Get(0).(int64), args.Bool(1), args.Error(2)
|
|
}
|
|
|
|
// CacheGetInt delegates to the mock instance.
|
|
// GetInt retrieves an integer value from the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns the value and whether the key exists. If the key doesn't exist
|
|
// or the stored value is not an integer, exists will be false.
|
|
func CacheGetInt(key string) (int64, bool, error) {
|
|
return CacheMock.GetInt(key)
|
|
}
|
|
|
|
// SetFloat is the mock method for CacheSetFloat.
|
|
func (m *mockCacheService) SetFloat(key string, value float64, ttlSeconds int64) error {
|
|
args := m.Called(key, value, ttlSeconds)
|
|
return args.Error(0)
|
|
}
|
|
|
|
// CacheSetFloat delegates to the mock instance.
|
|
// SetFloat stores a float value in the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
// - value: The float value to store
|
|
// - ttlSeconds: Time-to-live in seconds (0 uses default of 24 hours)
|
|
//
|
|
// Returns an error if the operation fails.
|
|
func CacheSetFloat(key string, value float64, ttlSeconds int64) error {
|
|
return CacheMock.SetFloat(key, value, ttlSeconds)
|
|
}
|
|
|
|
// GetFloat is the mock method for CacheGetFloat.
|
|
func (m *mockCacheService) GetFloat(key string) (float64, bool, error) {
|
|
args := m.Called(key)
|
|
return args.Get(0).(float64), args.Bool(1), args.Error(2)
|
|
}
|
|
|
|
// CacheGetFloat delegates to the mock instance.
|
|
// GetFloat retrieves a float value from the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns the value and whether the key exists. If the key doesn't exist
|
|
// or the stored value is not a float, exists will be false.
|
|
func CacheGetFloat(key string) (float64, bool, error) {
|
|
return CacheMock.GetFloat(key)
|
|
}
|
|
|
|
// SetBytes is the mock method for CacheSetBytes.
|
|
func (m *mockCacheService) SetBytes(key string, value []byte, ttlSeconds int64) error {
|
|
args := m.Called(key, value, ttlSeconds)
|
|
return args.Error(0)
|
|
}
|
|
|
|
// CacheSetBytes delegates to the mock instance.
|
|
// SetBytes stores a byte slice in the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
// - value: The byte slice to store
|
|
// - ttlSeconds: Time-to-live in seconds (0 uses default of 24 hours)
|
|
//
|
|
// Returns an error if the operation fails.
|
|
func CacheSetBytes(key string, value []byte, ttlSeconds int64) error {
|
|
return CacheMock.SetBytes(key, value, ttlSeconds)
|
|
}
|
|
|
|
// GetBytes is the mock method for CacheGetBytes.
|
|
func (m *mockCacheService) GetBytes(key string) ([]byte, bool, error) {
|
|
args := m.Called(key)
|
|
var r0 []byte
|
|
if v := args.Get(0); v != nil {
|
|
r0 = v.([]byte)
|
|
}
|
|
return r0, args.Bool(1), args.Error(2)
|
|
}
|
|
|
|
// CacheGetBytes delegates to the mock instance.
|
|
// GetBytes retrieves a byte slice from the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns the value and whether the key exists. If the key doesn't exist
|
|
// or the stored value is not a byte slice, exists will be false.
|
|
func CacheGetBytes(key string) ([]byte, bool, error) {
|
|
return CacheMock.GetBytes(key)
|
|
}
|
|
|
|
// Has is the mock method for CacheHas.
|
|
func (m *mockCacheService) Has(key string) (bool, error) {
|
|
args := m.Called(key)
|
|
return args.Bool(0), args.Error(1)
|
|
}
|
|
|
|
// CacheHas delegates to the mock instance.
|
|
// Has checks if a key exists in the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns true if the key exists and has not expired.
|
|
func CacheHas(key string) (bool, error) {
|
|
return CacheMock.Has(key)
|
|
}
|
|
|
|
// Remove is the mock method for CacheRemove.
|
|
func (m *mockCacheService) Remove(key string) error {
|
|
args := m.Called(key)
|
|
return args.Error(0)
|
|
}
|
|
|
|
// CacheRemove delegates to the mock instance.
|
|
// Remove deletes a value from the cache.
|
|
//
|
|
// Parameters:
|
|
// - key: The cache key (will be namespaced with plugin ID)
|
|
//
|
|
// Returns an error if the operation fails. Does not return an error if the key doesn't exist.
|
|
func CacheRemove(key string) error {
|
|
return CacheMock.Remove(key)
|
|
}
|