test: expand routing and compact coverage
This commit is contained in:
committed by
Steve Yegge
parent
cb280b0fad
commit
12b797781d
30
internal/compact/git_test.go
Normal file
30
internal/compact/git_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user