MCPcopy
hub / github.com/cli/cli / TestManager_Install_rosetta_fallback_not_found

Function TestManager_Install_rosetta_fallback_not_found

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

Source from the content-addressed store, hash-verified

1058}
1059
1060func TestManager_Install_rosetta_fallback_not_found(t *testing.T) {
1061 repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com")
1062
1063 reg := httpmock.Registry{}
1064 defer reg.Verify(t)
1065 client := http.Client{Transport: &reg}
1066
1067 reg.Register(
1068 httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
1069 httpmock.JSONResponse(
1070 release{
1071 Assets: []releaseAsset{
1072 {
1073 Name: "gh-bin-ext-darwin-amd64",
1074 APIURL: "https://example.com/release/cool",
1075 },
1076 },
1077 }))
1078 reg.Register(
1079 httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
1080 httpmock.JSONResponse(
1081 release{
1082 Tag: "v1.0.1",
1083 Assets: []releaseAsset{
1084 {
1085 Name: "gh-bin-ext-darwin-amd64",
1086 APIURL: "https://example.com/release/cool",
1087 },
1088 },
1089 }))
1090
1091 ios, _, stdout, stderr := iostreams.Test()
1092 dataDir := t.TempDir()
1093 updateDir := t.TempDir()
1094
1095 m := newTestManager(dataDir, updateDir, &client, nil, ios)
1096 m.platform = func() (string, string) {
1097 return "darwin-arm64", ""
1098 }
1099
1100 originalHasRosetta := hasRosetta
1101 t.Cleanup(func() { hasRosetta = originalHasRosetta })
1102 hasRosetta = func() bool {
1103 return false
1104 }
1105
1106 err := m.Install(repo, "")
1107 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'`")
1108
1109 assert.Equal(t, "", stdout.String())
1110 assert.Equal(t, "", stderr.String())
1111}
1112
1113func TestManager_Install_binary(t *testing.T) {
1114 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.45

Tested by

no test coverage detected