(t *testing.T)
| 486 | } |
| 487 | |
| 488 | func TestResolveGitRoot(t *testing.T) { |
| 489 | tests := []struct { |
| 490 | name string |
| 491 | client *git.Client |
| 492 | wantDir string |
| 493 | }{ |
| 494 | { |
| 495 | name: "returns RepoDir when set", |
| 496 | client: &git.Client{RepoDir: "/monalisa/repo"}, |
| 497 | wantDir: "/monalisa/repo", |
| 498 | }, |
| 499 | { |
| 500 | name: "nil client falls back to cwd", |
| 501 | client: nil, |
| 502 | }, |
| 503 | { |
| 504 | name: "empty RepoDir falls back to ToplevelDir or cwd", |
| 505 | client: &git.Client{}, |
| 506 | }, |
| 507 | } |
| 508 | for _, tt := range tests { |
| 509 | t.Run(tt.name, func(t *testing.T) { |
| 510 | got := ResolveGitRoot(tt.client) |
| 511 | if tt.wantDir != "" { |
| 512 | assert.Equal(t, tt.wantDir, got) |
| 513 | } else { |
| 514 | assert.NotEmpty(t, got, "should fall back to ToplevelDir or cwd") |
| 515 | } |
| 516 | }) |
| 517 | } |
| 518 | } |
nothing calls this directly
no test coverage detected