Documentation
¶
Index ¶
- type FileEvent
- type MockLSPClient
- func (m *MockLSPClient) CountEvents(uri string, eventType protocol.FileChangeType) int
- func (m *MockLSPClient) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error
- func (m *MockLSPClient) GetEvents() []FileEvent
- func (m *MockLSPClient) IsFileOpen(path string) bool
- func (m *MockLSPClient) NotifyChange(ctx context.Context, path string) error
- func (m *MockLSPClient) OpenFile(ctx context.Context, path string) error
- func (m *MockLSPClient) ResetEvents()
- func (m *MockLSPClient) SetFileWatchHandler(handler func(id string, watchers []protocol.FileSystemWatcher))
- func (m *MockLSPClient) WaitForEvent(ctx context.Context) bool
- func (m *MockLSPClient) WaitForEventType(ctx context.Context, uri string, eventType protocol.FileChangeType) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileEvent ¶
type FileEvent struct {
URI string
Type protocol.FileChangeType
}
FileEvent represents a file event notification
type MockLSPClient ¶
type MockLSPClient struct {
// contains filtered or unexported fields
}
MockLSPClient implements the watcher.LSPClient interface for testing
func NewMockLSPClient ¶
func NewMockLSPClient() *MockLSPClient
NewMockLSPClient creates a new mock LSP client for testing
func (*MockLSPClient) CountEvents ¶
func (m *MockLSPClient) CountEvents(uri string, eventType protocol.FileChangeType) int
CountEvents counts events for a specific file and event type
func (*MockLSPClient) DidChangeWatchedFiles ¶
func (m *MockLSPClient) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error
DidChangeWatchedFiles mocks sending watched file events to the server
func (*MockLSPClient) GetEvents ¶
func (m *MockLSPClient) GetEvents() []FileEvent
GetEvents returns a copy of all recorded events
func (*MockLSPClient) IsFileOpen ¶
func (m *MockLSPClient) IsFileOpen(path string) bool
IsFileOpen checks if a file is already open in the editor
func (*MockLSPClient) NotifyChange ¶
func (m *MockLSPClient) NotifyChange(ctx context.Context, path string) error
NotifyChange mocks notifying the server of a file change
func (*MockLSPClient) OpenFile ¶
func (m *MockLSPClient) OpenFile(ctx context.Context, path string) error
OpenFile mocks opening a file in the editor
func (*MockLSPClient) ResetEvents ¶
func (m *MockLSPClient) ResetEvents()
ResetEvents clears the recorded events and drains any pending notification signals from previous activity (e.g. workspace scan, prior subtests). Without the drain, WaitForEvent could return immediately on a stale signal before the watcher's debounce fires for the new event under test, racing with the CountEvents check and producing the "No create event received" flake.
func (*MockLSPClient) SetFileWatchHandler ¶ added in v0.3.0
func (m *MockLSPClient) SetFileWatchHandler(handler func(id string, watchers []protocol.FileSystemWatcher))
SetFileWatchHandler satisfies the watcher.LSPClient interface. Tests using MockLSPClient don't exercise server-driven file-watch registrations, so this is intentionally a no-op.
func (*MockLSPClient) WaitForEvent ¶
func (m *MockLSPClient) WaitForEvent(ctx context.Context) bool
WaitForEvent waits for at least one event to be received or context to be done
func (*MockLSPClient) WaitForEventType ¶
func (m *MockLSPClient) WaitForEventType(ctx context.Context, uri string, eventType protocol.FileChangeType) bool
WaitForEventType waits until an event matching uri+eventType has been recorded, or the context is done. This is the race-free variant for tests that assert on a specific event: WaitForEvent returns on the *first* signal, but a newly-created file produces both a Changed and a Created event (the watcher routes the Write-after-Create through NotifyChange because it just auto-opened the file). Tests waiting for the Created event must keep draining signals until the matching event lands.