test: expand compact and ui coverage

This commit is contained in:
Jordan Hubbard
2025-12-29 19:32:38 -04:00
committed by Steve Yegge
parent d3b6855aa9
commit c9fa7af04c
7 changed files with 639 additions and 30 deletions

View File

@@ -203,6 +203,26 @@ func TestDetectUserRole_ConfigOverrideMaintainer(t *testing.T) {
}
}
func TestDetectUserRole_ConfigOverrideContributor(t *testing.T) {
orig := gitCommandRunner
stub := &gitStub{t: t, responses: []gitResponse{
{expect: gitCall{"/repo", []string{"config", "--get", "beads.role"}}, output: "contributor\n"},
}}
gitCommandRunner = stub.run
t.Cleanup(func() {
gitCommandRunner = orig
stub.verify()
})
role, err := DetectUserRole("/repo")
if err != nil {
t.Fatalf("DetectUserRole error = %v", err)
}
if role != Contributor {
t.Fatalf("expected %s, got %s", Contributor, role)
}
}
func TestDetectUserRole_PushURLMaintainer(t *testing.T) {
orig := gitCommandRunner
stub := &gitStub{t: t, responses: []gitResponse{
@@ -224,6 +244,27 @@ func TestDetectUserRole_PushURLMaintainer(t *testing.T) {
}
}
func TestDetectUserRole_HTTPSCredentialsMaintainer(t *testing.T) {
orig := gitCommandRunner
stub := &gitStub{t: t, responses: []gitResponse{
{expect: gitCall{"/repo", []string{"config", "--get", "beads.role"}}, output: ""},
{expect: gitCall{"/repo", []string{"remote", "get-url", "--push", "origin"}}, output: "https://token@github.com/owner/repo.git"},
}}
gitCommandRunner = stub.run
t.Cleanup(func() {
gitCommandRunner = orig
stub.verify()
})
role, err := DetectUserRole("/repo")
if err != nil {
t.Fatalf("DetectUserRole error = %v", err)
}
if role != Maintainer {
t.Fatalf("expected %s, got %s", Maintainer, role)
}
}
func TestDetectUserRole_DefaultContributor(t *testing.T) {
orig := gitCommandRunner
stub := &gitStub{t: t, responses: []gitResponse{