TestBuildCheckoutsPromptContent verifies the prompt content generation for the checkout list.
(t *testing.T)
| 689 | |
| 690 | // TestBuildCheckoutsPromptContent verifies the prompt content generation for the checkout list. |
| 691 | func TestBuildCheckoutsPromptContent(t *testing.T) { |
| 692 | t.Run("nil slice returns empty string", func(t *testing.T) { |
| 693 | assert.Empty(t, buildCheckoutsPromptContent(nil), "nil should return empty string") |
| 694 | }) |
| 695 | |
| 696 | t.Run("empty slice returns empty string", func(t *testing.T) { |
| 697 | assert.Empty(t, buildCheckoutsPromptContent([]*CheckoutConfig{}), "empty slice should return empty string") |
| 698 | }) |
| 699 | |
| 700 | t.Run("default checkout with no repo uses github.repository expression and cwd", func(t *testing.T) { |
| 701 | content := buildCheckoutsPromptContent([]*CheckoutConfig{ |
| 702 | {}, |
| 703 | }) |
| 704 | assert.Contains(t, content, "$GITHUB_WORKSPACE", "should show full workspace path for root checkout") |
| 705 | assert.Contains(t, content, "(cwd)", "root checkout should be marked as cwd") |
| 706 | assert.Contains(t, content, "${{ github.repository }}", "should reference github.repository expression for default checkout") |
| 707 | }) |
| 708 | |
| 709 | t.Run("checkout with explicit repo shows full path", func(t *testing.T) { |
| 710 | content := buildCheckoutsPromptContent([]*CheckoutConfig{ |
| 711 | {Repository: "owner/target", Path: "./target"}, |
| 712 | }) |
| 713 | assert.Contains(t, content, "repo `owner/target` → `$GITHUB_WORKSPACE/target`", "should present checkout as repo-to-directory mapping") |
| 714 | assert.Contains(t, content, "$GITHUB_WORKSPACE/target", "should show full workspace path") |
| 715 | assert.Contains(t, content, "owner/target", "should show the configured repo") |
| 716 | assert.NotContains(t, content, "github.repository", "should not include github.repository expression for explicit repo") |
| 717 | assert.NotContains(t, content, "(cwd)", "non-root checkout should not be marked as cwd") |
| 718 | }) |
| 719 | |
| 720 | t.Run("current checkout is marked", func(t *testing.T) { |
| 721 | content := buildCheckoutsPromptContent([]*CheckoutConfig{ |
| 722 | {Repository: "owner/target", Path: "./target", Current: true}, |
| 723 | }) |
| 724 | assert.Contains(t, content, "**current**", "current checkout should be marked") |
| 725 | assert.Contains(t, content, "this is the repository you are working on", "current checkout should have instructions") |
| 726 | }) |
| 727 | |
| 728 | t.Run("non-current checkout is not marked", func(t *testing.T) { |
| 729 | content := buildCheckoutsPromptContent([]*CheckoutConfig{ |
| 730 | {Repository: "owner/libs", Path: "./libs"}, |
| 731 | }) |
| 732 | assert.NotContains(t, content, "**current**", "non-current checkout should not be marked") |
| 733 | }) |
| 734 | |
| 735 | t.Run("multiple checkouts all listed", func(t *testing.T) { |
| 736 | content := buildCheckoutsPromptContent([]*CheckoutConfig{ |
| 737 | {Path: ""}, |
| 738 | {Repository: "owner/target", Path: "./target", Current: true}, |
| 739 | {Repository: "owner/libs", Path: "./libs"}, |
| 740 | }) |
| 741 | assert.Contains(t, content, "$GITHUB_WORKSPACE", "should include workspace root for root checkout") |
| 742 | assert.Contains(t, content, "(cwd)", "root checkout should be marked as cwd") |
| 743 | assert.Contains(t, content, "$GITHUB_WORKSPACE/target", "should include full path for target checkout") |
| 744 | assert.Contains(t, content, "owner/target", "should include target repo") |
| 745 | assert.Contains(t, content, "$GITHUB_WORKSPACE/libs", "should include full path for libs checkout") |
| 746 | assert.Contains(t, content, "owner/libs", "should include libs repo") |
| 747 | assert.Contains(t, content, "**current**", "current checkout should be marked") |
| 748 | }) |
nothing calls this directly
no test coverage detected