(t *testing.T)
| 1182 | } |
| 1183 | |
| 1184 | func TestManager_Install_amd64_when_supported(t *testing.T) { |
| 1185 | repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com") |
| 1186 | |
| 1187 | reg := httpmock.Registry{} |
| 1188 | defer reg.Verify(t) |
| 1189 | client := http.Client{Transport: ®} |
| 1190 | |
| 1191 | reg.Register( |
| 1192 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1193 | httpmock.JSONResponse( |
| 1194 | release{ |
| 1195 | Assets: []releaseAsset{ |
| 1196 | { |
| 1197 | Name: "gh-bin-ext-darwin-amd64", |
| 1198 | APIURL: "https://example.com/release/cool", |
| 1199 | }, |
| 1200 | }, |
| 1201 | })) |
| 1202 | reg.Register( |
| 1203 | httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"), |
| 1204 | httpmock.JSONResponse( |
| 1205 | release{ |
| 1206 | Tag: "v1.0.1", |
| 1207 | Assets: []releaseAsset{ |
| 1208 | { |
| 1209 | Name: "gh-bin-ext-darwin-amd64", |
| 1210 | APIURL: "https://example.com/release/cool", |
| 1211 | }, |
| 1212 | }, |
| 1213 | })) |
| 1214 | reg.Register( |
| 1215 | httpmock.REST("GET", "release/cool"), |
| 1216 | httpmock.StringResponse("FAKE BINARY")) |
| 1217 | |
| 1218 | ios, _, stdout, stderr := iostreams.Test() |
| 1219 | dataDir := t.TempDir() |
| 1220 | updateDir := t.TempDir() |
| 1221 | |
| 1222 | m := newTestManager(dataDir, updateDir, &client, nil, ios) |
| 1223 | m.platform = func() (string, string) { |
| 1224 | return "darwin-arm64", "" |
| 1225 | } |
| 1226 | |
| 1227 | originalHasRosetta := hasRosetta |
| 1228 | t.Cleanup(func() { hasRosetta = originalHasRosetta }) |
| 1229 | hasRosetta = func() bool { |
| 1230 | return true |
| 1231 | } |
| 1232 | |
| 1233 | err := m.Install(repo, "") |
| 1234 | assert.NoError(t, err) |
| 1235 | |
| 1236 | manifest, err := os.ReadFile(filepath.Join(dataDir, "extensions/gh-bin-ext", manifestName)) |
| 1237 | assert.NoError(t, err) |
| 1238 | |
| 1239 | var bm binManifest |
| 1240 | err = yaml.Unmarshal(manifest, &bm) |
| 1241 | assert.NoError(t, err) |
nothing calls this directly
no test coverage detected