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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user