// 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" // mockWebSocketService is the mock implementation for testing. type mockWebSocketService struct { mock.Mock } // WebSocketMock is the auto-instantiated mock instance for testing. // Use this to set expectations: host.WebSocketMock.On("MethodName", args...).Return(values...) var WebSocketMock = &mockWebSocketService{} // Connect is the mock method for WebSocketConnect. func (m *mockWebSocketService) Connect(url string, headers map[string]string, connectionID string) (string, error) { args := m.Called(url, headers, connectionID) return args.String(0), args.Error(1) } // WebSocketConnect delegates to the mock instance. // Connect establishes a WebSocket connection to the specified URL. // // Plugins that use this function must also implement the WebSocketCallback capability // to receive incoming messages and connection events. // // Parameters: // - url: The WebSocket URL to connect to (ws:// or wss://) // - headers: Optional HTTP headers to include in the handshake request // - connectionID: Optional unique identifier for the connection. If empty, one will be generated // // Returns the connection ID that can be used to send messages or close the connection, // or an error if the connection fails. func WebSocketConnect(url string, headers map[string]string, connectionID string) (string, error) { return WebSocketMock.Connect(url, headers, connectionID) } // SendText is the mock method for WebSocketSendText. func (m *mockWebSocketService) SendText(connectionID string, message string) error { args := m.Called(connectionID, message) return args.Error(0) } // WebSocketSendText delegates to the mock instance. // SendText sends a text message over an established WebSocket connection. // // Parameters: // - connectionID: The connection identifier returned by Connect // - message: The text message to send // // Returns an error if the connection is not found or if sending fails. func WebSocketSendText(connectionID string, message string) error { return WebSocketMock.SendText(connectionID, message) } // SendBinary is the mock method for WebSocketSendBinary. func (m *mockWebSocketService) SendBinary(connectionID string, data []byte) error { args := m.Called(connectionID, data) return args.Error(0) } // WebSocketSendBinary delegates to the mock instance. // SendBinary sends binary data over an established WebSocket connection. // // Parameters: // - connectionID: The connection identifier returned by Connect // - data: The binary data to send // // Returns an error if the connection is not found or if sending fails. func WebSocketSendBinary(connectionID string, data []byte) error { return WebSocketMock.SendBinary(connectionID, data) } // CloseConnection is the mock method for WebSocketCloseConnection. func (m *mockWebSocketService) CloseConnection(connectionID string, code int32, reason string) error { args := m.Called(connectionID, code, reason) return args.Error(0) } // WebSocketCloseConnection delegates to the mock instance. // CloseConnection gracefully closes a WebSocket connection. // // Parameters: // - connectionID: The connection identifier returned by Connect // - code: WebSocket close status code (e.g., 1000 for normal closure) // - reason: Optional human-readable reason for closing // // Returns an error if the connection is not found or if closing fails. func WebSocketCloseConnection(connectionID string, code int32, reason string) error { return WebSocketMock.CloseConnection(connectionID, code, reason) }