(t *testing.T)
| 1258 | } |
| 1259 | |
| 1260 | func TestManager_Install_amd64_when_supported(t *testing.T) { |
| 1261 | repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com") |
| 1262 | |
| 1263 | reg := httpmock.Registry{} |
| 1264 | defer reg.Verify(t) |
| 1265 | client := http.Client{Transport: ®} |
| 1266 | |
| 1267 | reg.Register( |
| 1268 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1269 | httpmock.JSONResponse( |
| 1270 | release{ |
| 1271 | Assets: []releaseAsset{ |
| 1272 | { |
| 1273 | Name: "gh-bin-ext-darwin-amd64", |
| 1274 | APIURL: "https://example.com/release/cool", |
| 1275 | }, |
| 1276 | }, |
| 1277 | })) |
| 1278 | reg.Register( |
| 1279 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1280 | httpmock.JSONResponse( |
| 1281 | release{ |
| 1282 | Tag: "v1.0.1", |
| 1283 | Assets: []releaseAsset{ |
| 1284 | { |
| 1285 | Name: "gh-bin-ext-darwin-amd64", |
| 1286 | APIURL: "https://example.com/release/cool", |
| 1287 | }, |
| 1288 | }, |
| 1289 | })) |
| 1290 | reg.Register( |
| 1291 | httpmock.REST("GET", "release/cool"), |
| 1292 | httpmock.StringResponse("FAKE BINARY")) |
| 1293 | |
| 1294 | ios, _, stdout, stderr := iostreams.Test() |
| 1295 | dataDir := t.TempDir() |
| 1296 | updateDir := t.TempDir() |
| 1297 | |
| 1298 | m := newTestManager(dataDir, updateDir, &client, nil, ios) |
| 1299 | m.platform = func() (string, string) { |
| 1300 | return "darwin-arm64", "" |
| 1301 | } |
| 1302 | |
| 1303 | originalHasRosetta := hasRosetta |
| 1304 | t.Cleanup(func() { hasRosetta = originalHasRosetta }) |
| 1305 | hasRosetta = func() bool { |
| 1306 | return true |
| 1307 | } |
| 1308 | |
| 1309 | err := m.Install(repo, "") |
| 1310 | assert.NoError(t, err) |
| 1311 | |
| 1312 | manifest, err := os.ReadFile(filepath.Join(dataDir, "extensions/gh-bin-ext", manifestName)) |
| 1313 | assert.NoError(t, err) |
| 1314 | |
| 1315 | var bm binManifest |
| 1316 | err = yaml.Unmarshal(manifest, &bm) |
| 1317 | assert.NoError(t, err) |
nothing calls this directly
no test coverage detected