(t *testing.T)
| 1134 | } |
| 1135 | |
| 1136 | func TestManager_Install_rosetta_fallback_not_found(t *testing.T) { |
| 1137 | repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com") |
| 1138 | |
| 1139 | reg := httpmock.Registry{} |
| 1140 | defer reg.Verify(t) |
| 1141 | client := http.Client{Transport: ®} |
| 1142 | |
| 1143 | reg.Register( |
| 1144 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1145 | httpmock.JSONResponse( |
| 1146 | release{ |
| 1147 | Assets: []releaseAsset{ |
| 1148 | { |
| 1149 | Name: "gh-bin-ext-darwin-amd64", |
| 1150 | APIURL: "https://example.com/release/cool", |
| 1151 | }, |
| 1152 | }, |
| 1153 | })) |
| 1154 | reg.Register( |
| 1155 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1156 | httpmock.JSONResponse( |
| 1157 | release{ |
| 1158 | Tag: "v1.0.1", |
| 1159 | Assets: []releaseAsset{ |
| 1160 | { |
| 1161 | Name: "gh-bin-ext-darwin-amd64", |
| 1162 | APIURL: "https://example.com/release/cool", |
| 1163 | }, |
| 1164 | }, |
| 1165 | })) |
| 1166 | |
| 1167 | ios, _, stdout, stderr := iostreams.Test() |
| 1168 | dataDir := t.TempDir() |
| 1169 | updateDir := t.TempDir() |
| 1170 | |
| 1171 | m := newTestManager(dataDir, updateDir, &client, nil, ios) |
| 1172 | m.platform = func() (string, string) { |
| 1173 | return "darwin-arm64", "" |
| 1174 | } |
| 1175 | |
| 1176 | originalHasRosetta := hasRosetta |
| 1177 | t.Cleanup(func() { hasRosetta = originalHasRosetta }) |
| 1178 | hasRosetta = func() bool { |
| 1179 | return false |
| 1180 | } |
| 1181 | |
| 1182 | err := m.Install(repo, "") |
| 1183 | assert.EqualError(t, err, "gh-bin-ext unsupported for darwin-arm64. Install Rosetta with `softwareupdate --install-rosetta` to use the available darwin-amd64 binary, or open an issue: `gh issue create -R owner/gh-bin-ext -t'Support darwin-arm64'`") |
| 1184 | |
| 1185 | assert.Equal(t, "", stdout.String()) |
| 1186 | assert.Equal(t, "", stderr.String()) |
| 1187 | } |
| 1188 | |
| 1189 | func TestManager_Install_binary(t *testing.T) { |
| 1190 | fakeExtensionName := "gh-bin-ext" |
nothing calls this directly
no test coverage detected