navidrome/plugins/pdk/go/host/nd_host_users_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

71 lines
2.2 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"
)
// User represents the User data structure.
// User represents a Navidrome user with minimal information exposed to plugins.
// Sensitive fields like password, email, and internal IDs are intentionally excluded.
type User struct {
UserName string `json:"userName"`
Name string `json:"name"`
IsAdmin bool `json:"isAdmin"`
}
// mockUsersService is the mock implementation for testing.
type mockUsersService struct {
mock.Mock
}
// UsersMock is the auto-instantiated mock instance for testing.
// Use this to set expectations: host.UsersMock.On("MethodName", args...).Return(values...)
var UsersMock = &mockUsersService{}
// GetUsers is the mock method for UsersGetUsers.
func (m *mockUsersService) GetUsers() ([]User, error) {
args := m.Called()
var r0 []User
if v := args.Get(0); v != nil {
r0 = v.([]User)
}
return r0, args.Error(1)
}
// UsersGetUsers delegates to the mock instance.
// GetUsers returns all users the plugin has been granted access to.
// Only minimal user information (userName, name, isAdmin) is returned.
// Sensitive fields like password and email are never exposed.
//
// Returns a slice of users the plugin can access, or an empty slice if none configured.
func UsersGetUsers() ([]User, error) {
return UsersMock.GetUsers()
}
// GetAdmins is the mock method for UsersGetAdmins.
func (m *mockUsersService) GetAdmins() ([]User, error) {
args := m.Called()
var r0 []User
if v := args.Get(0); v != nil {
r0 = v.([]User)
}
return r0, args.Error(1)
}
// UsersGetAdmins delegates to the mock instance.
// GetAdmins returns only admin users the plugin has been granted access to.
// This is a convenience method that filters GetUsers results to include only admins.
//
// Returns a slice of admin users the plugin can access, or an empty slice if none.
func UsersGetAdmins() ([]User, error) {
return UsersMock.GetAdmins()
}