TestCloneRepoWithVersion tests that parseRepoSpec correctly handles version specifications and that the version is properly passed to cloneRepoContentsIntoHost
(t *testing.T)
| 92 | // TestCloneRepoWithVersion tests that parseRepoSpec correctly handles version specifications |
| 93 | // and that the version is properly passed to cloneRepoContentsIntoHost |
| 94 | func TestCloneRepoWithVersion(t *testing.T) { |
| 95 | setHostEnv := func(t *testing.T, ghHost string) { |
| 96 | t.Helper() |
| 97 | t.Setenv("GITHUB_SERVER_URL", "") |
| 98 | t.Setenv("GITHUB_ENTERPRISE_HOST", "") |
| 99 | t.Setenv("GITHUB_HOST", "") |
| 100 | t.Setenv("GH_HOST", ghHost) |
| 101 | } |
| 102 | |
| 103 | tests := []struct { |
| 104 | name string |
| 105 | cloneRepoSpec string |
| 106 | ghHost string |
| 107 | expectedSlug string |
| 108 | expectedVersion string |
| 109 | shouldError bool |
| 110 | description string |
| 111 | }{ |
| 112 | { |
| 113 | name: "repo with tag", |
| 114 | cloneRepoSpec: "owner/repo@v1.0.0", |
| 115 | expectedSlug: "owner/repo", |
| 116 | expectedVersion: "v1.0.0", |
| 117 | shouldError: false, |
| 118 | description: "Should parse tag version correctly", |
| 119 | }, |
| 120 | { |
| 121 | name: "repo with branch", |
| 122 | cloneRepoSpec: "owner/repo@main", |
| 123 | expectedSlug: "owner/repo", |
| 124 | expectedVersion: "main", |
| 125 | shouldError: false, |
| 126 | description: "Should parse branch name correctly", |
| 127 | }, |
| 128 | { |
| 129 | name: "repo with commit SHA", |
| 130 | cloneRepoSpec: "owner/repo@abc123def456", |
| 131 | expectedSlug: "owner/repo", |
| 132 | expectedVersion: "abc123def456", |
| 133 | shouldError: false, |
| 134 | description: "Should parse commit SHA correctly", |
| 135 | }, |
| 136 | { |
| 137 | name: "repo without version", |
| 138 | cloneRepoSpec: "owner/repo", |
| 139 | expectedSlug: "owner/repo", |
| 140 | expectedVersion: "", |
| 141 | shouldError: false, |
| 142 | description: "Should handle repo without version", |
| 143 | }, |
| 144 | { |
| 145 | name: "GitHub URL with tag", |
| 146 | cloneRepoSpec: "https://github.com/owner/repo@v2.1.0", |
| 147 | ghHost: "", |
| 148 | expectedSlug: "owner/repo", |
| 149 | expectedVersion: "v2.1.0", |
| 150 | shouldError: false, |
| 151 | description: "Should parse GitHub URL with tag", |
nothing calls this directly
no test coverage detected