Files
webterm/webterm/test_helpers_test.go
T
GitHub Copilot 98e000e3be Fix module path mismatch for go install
Resolve GitHub issue #2 by aligning the Go module identity with the repository path so  works.

Changes made:
- Updated go.mod module path from github.com/rcarmo/webterm-go-port to github.com/rcarmo/webterm.
- Updated all internal import references to the new module path.
- Updated version ldflags in Makefile and Dockerfile to use github.com/rcarmo/webterm/webterm.Version.
- Added README quick-install section documenting the  command.

Validation:
- Ran make check successfully after the rename/import updates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-15 16:19:46 +00:00

103 lines
2.0 KiB
Go

package webterm
import (
"sync"
"github.com/rcarmo/webterm/internal/terminalstate"
)
type fakeSession struct {
mu sync.Mutex
running bool
replay []byte
snapshot terminalstate.Snapshot
received [][]byte
width int
height int
connector SessionConnector
}
func newFakeSession() *fakeSession {
return &fakeSession{
snapshot: terminalstate.Snapshot{
Width: 80,
Height: 24,
Buffer: [][]terminalstate.Cell{{{Data: "h", FG: "default", BG: "default"}}},
HasChanges: true,
},
}
}
func (f *fakeSession) Open(width, height int) error {
f.mu.Lock()
defer f.mu.Unlock()
f.running = true
f.width = width
f.height = height
f.snapshot.Width = width
f.snapshot.Height = height
return nil
}
func (f *fakeSession) Start(connector SessionConnector) error {
f.mu.Lock()
defer f.mu.Unlock()
f.connector = connector
return nil
}
func (f *fakeSession) Close() error {
f.mu.Lock()
defer f.mu.Unlock()
f.running = false
return nil
}
func (f *fakeSession) Wait() error { return nil }
func (f *fakeSession) SetTerminalSize(width, height int) error {
f.mu.Lock()
defer f.mu.Unlock()
f.width = width
f.height = height
f.snapshot.Width = width
f.snapshot.Height = height
return nil
}
func (f *fakeSession) SendBytes(data []byte) bool {
f.mu.Lock()
defer f.mu.Unlock()
chunk := append([]byte{}, data...)
f.received = append(f.received, chunk)
return true
}
func (f *fakeSession) SendMeta(_ map[string]any) bool { return true }
func (f *fakeSession) IsRunning() bool {
f.mu.Lock()
defer f.mu.Unlock()
return f.running
}
func (f *fakeSession) GetReplayBuffer() []byte {
f.mu.Lock()
defer f.mu.Unlock()
return append([]byte{}, f.replay...)
}
func (f *fakeSession) GetScreenSnapshot() terminalstate.Snapshot {
f.mu.Lock()
defer f.mu.Unlock()
return f.snapshot
}
func (f *fakeSession) ForceRedraw() error { return nil }
func (f *fakeSession) UpdateConnector(connector SessionConnector) {
f.mu.Lock()
defer f.mu.Unlock()
f.connector = connector
}