MCPcopy Create free account
hub / github.com/cli/cli / TestManager_Install_rosetta_fallback_not_found

Function TestManager_Install_rosetta_fallback_not_found

pkg/cmd/extension/manager_test.go:1136–1187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1134}
1135
1136func 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: &reg}
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
1189func TestManager_Install_binary(t *testing.T) {
1190 fakeExtensionName := "gh-bin-ext"

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
NewWithHostFunction · 0.92
RESTFunction · 0.92
JSONResponseFunction · 0.92
TestFunction · 0.92
newTestManagerFunction · 0.85
EqualMethod · 0.80
InstallMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected