MCPcopy
hub / github.com/cli/cli / TestManager_Install_binary_pinned

Function TestManager_Install_binary_pinned

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

Source from the content-addressed store, hash-verified

947}
948
949func TestManager_Install_binary_pinned(t *testing.T) {
950 repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com")
951
952 reg := httpmock.Registry{}
953 defer reg.Verify(t)
954
955 reg.Register(
956 httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
957 httpmock.JSONResponse(
958 release{
959 Assets: []releaseAsset{
960 {
961 Name: "gh-bin-ext-windows-amd64.exe",
962 APIURL: "https://example.com/release/cool",
963 },
964 },
965 }))
966 reg.Register(
967 httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/tags/v1.6.3-pre"),
968 httpmock.JSONResponse(
969 release{
970 Tag: "v1.6.3-pre",
971 Assets: []releaseAsset{
972 {
973 Name: "gh-bin-ext-windows-amd64.exe",
974 APIURL: "https://example.com/release/cool",
975 },
976 },
977 }))
978 reg.Register(
979 httpmock.REST("GET", "release/cool"),
980 httpmock.StringResponse("FAKE BINARY"))
981
982 ios, _, stdout, stderr := iostreams.Test()
983 dataDir := t.TempDir()
984 updateDir := t.TempDir()
985
986 m := newTestManager(dataDir, updateDir, &http.Client{Transport: &reg}, nil, ios)
987
988 err := m.Install(repo, "v1.6.3-pre")
989 assert.NoError(t, err)
990
991 manifest, err := os.ReadFile(filepath.Join(dataDir, "extensions/gh-bin-ext", manifestName))
992 assert.NoError(t, err)
993
994 var bm binManifest
995 err = yaml.Unmarshal(manifest, &bm)
996 assert.NoError(t, err)
997
998 assert.Equal(t, binManifest{
999 Name: "gh-bin-ext",
1000 Owner: "owner",
1001 Host: "example.com",
1002 Tag: "v1.6.3-pre",
1003 IsPinned: true,
1004 Path: filepath.Join(dataDir, "extensions/gh-bin-ext/gh-bin-ext.exe"),
1005 }, bm)
1006

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected