e8863ed147
* feat: implement raw binary framing for host function responses Signed-off-by: Deluan <deluan@navidrome.org> * feat: add CallRaw method for Subsonic API to handle binary responses Signed-off-by: Deluan <deluan@navidrome.org> * test: add tests for raw=true methods and binary framing generation Signed-off-by: Deluan <deluan@navidrome.org> * fix: improve error message for malformed raw responses to indicate incomplete header Signed-off-by: Deluan <deluan@navidrome.org> * fix: add wasm_import_module attribute for raw methods and improve content-type handling Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
50 lines
1.8 KiB
Go
50 lines
1.8 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)
|
|
return args.String(0), args.Get(1).([]byte), args.Error(2)
|
|
}
|
|
|
|
// SubsonicAPICallRaw delegates to the mock instance.
|
|
// CallRaw executes a Subsonic API request and returns the raw binary response.
|
|
// Optimized for binary endpoints like getCoverArt and stream that return
|
|
// non-JSON data. The response is returned as raw bytes without JSON encoding overhead.
|
|
func SubsonicAPICallRaw(uri string) (string, []byte, error) {
|
|
return SubsonicAPIMock.CallRaw(uri)
|
|
}
|