test: expand routing and compact coverage

This commit is contained in:
Jordan Hubbard
2025-12-29 00:55:44 -04:00
committed by Steve Yegge
parent cb280b0fad
commit 12b797781d
4 changed files with 168 additions and 40 deletions

View File

@@ -0,0 +1,30 @@
package compact
import (
"errors"
"testing"
)
func TestGetCurrentCommitHashSuccess(t *testing.T) {
orig := gitExec
gitExec = func(string, ...string) ([]byte, error) {
return []byte("abc123\n"), nil
}
t.Cleanup(func() { gitExec = orig })
if got := GetCurrentCommitHash(); got != "abc123" {
t.Fatalf("expected trimmed hash, got %q", got)
}
}
func TestGetCurrentCommitHashError(t *testing.T) {
orig := gitExec
gitExec = func(string, ...string) ([]byte, error) {
return nil, errors.New("boom")
}
t.Cleanup(func() { gitExec = orig })
if got := GetCurrentCommitHash(); got != "" {
t.Fatalf("expected empty string on error, got %q", got)
}
}