test: expand Go fuzzing and raise coverage above 80%

- Add comprehensive runtime tests for session, docker watcher/stats/http, and server helpers
- Add new fuzz targets: FuzzToIntFromQuery and FuzzHTMLHelpers
- Add cmd/webterm main entrypoint test
- Expand helper conversion and color-mode coverage tests

Validation:
- go test ./...
- go test -race ./...
- All 15 fuzz targets pass with short fuzz runs
- go test ./... -coverpkg=./... => 80.9% total statement coverage

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
GitHub Copilot
2026-02-14 17:06:52 +00:00
parent 5aa9eb9426
commit f597f8f99d
5 changed files with 898 additions and 1 deletions
+23 -1
View File
@@ -1,6 +1,10 @@
package terminalstate
import "testing"
import (
"testing"
"github.com/rcarmo/go-te/pkg/te"
)
func TestTrackerSnapshotChangeTracking(t *testing.T) {
tracker := NewTracker(10, 3)
@@ -52,6 +56,24 @@ func TestTrackerResize(t *testing.T) {
}
}
func TestColorToStringModes(t *testing.T) {
if got := colorToString(te.Color{Mode: te.ColorDefault}); got != "default" {
t.Fatalf("default color mismatch: %q", got)
}
if got := colorToString(te.Color{Mode: te.ColorANSI16, Index: 1}); got != "red" {
t.Fatalf("ansi16 color mismatch: %q", got)
}
if got := colorToString(te.Color{Mode: te.ColorANSI256, Index: 196}); got != "196" {
t.Fatalf("ansi256 color mismatch: %q", got)
}
if got := colorToString(te.Color{Name: "#AABBCC"}); got != "aabbcc" {
t.Fatalf("named hex color mismatch: %q", got)
}
if got := colorToString(te.Color{Name: "Blue"}); got != "blue" {
t.Fatalf("named color mismatch: %q", got)
}
}
func FuzzTrackerFeed(f *testing.F) {
f.Add([]byte("hello world"))
f.Add([]byte("\x1b[31;1mRed Bold\x1b[0m"))