MCPcopy
hub / github.com/cli/cli / TestManager_Install_git_pinned

Function TestManager_Install_git_pinned

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

Source from the content-addressed store, hash-verified

901}
902
903func TestManager_Install_git_pinned(t *testing.T) {
904 dataDir := t.TempDir()
905 updateDir := t.TempDir()
906
907 reg := httpmock.Registry{}
908 defer reg.Verify(t)
909 client := http.Client{Transport: &reg}
910
911 ios, _, stdout, stderr := iostreams.Test()
912
913 extensionDir := filepath.Join(dataDir, "extensions", "gh-cool-ext")
914 gc, gcOne := &mockGitClient{}, &mockGitClient{}
915 gc.On("ForRepo", extensionDir).Return(gcOne).Once()
916 gc.On("Clone", "https://github.com/owner/gh-cool-ext.git", []string{extensionDir}).Return("", nil).Once()
917 gcOne.On("CheckoutBranch", "abcd1234").Return(nil).Once()
918
919 m := newTestManager(dataDir, updateDir, &client, gc, ios)
920
921 reg.Register(
922 httpmock.REST("GET", "repos/owner/gh-cool-ext/releases/latest"),
923 httpmock.JSONResponse(
924 release{
925 Assets: []releaseAsset{
926 {
927 Name: "not-a-binary",
928 APIURL: "https://example.com/release/cool",
929 },
930 },
931 }))
932 reg.Register(
933 httpmock.REST("GET", "repos/owner/gh-cool-ext/commits/some-ref"),
934 httpmock.StringResponse("abcd1234"))
935 reg.Register(
936 httpmock.REST("GET", "repos/owner/gh-cool-ext/contents/gh-cool-ext"),
937 httpmock.StringResponse("script"))
938
939 _ = os.MkdirAll(filepath.Join(m.installDir(), "gh-cool-ext"), 0700)
940 repo := ghrepo.New("owner", "gh-cool-ext")
941 err := m.Install(repo, "some-ref")
942 assert.NoError(t, err)
943 assert.Equal(t, "", stderr.String())
944 assert.Equal(t, "", stdout.String())
945 gc.AssertExpectations(t)
946 gcOne.AssertExpectations(t)
947}
948
949func TestManager_Install_binary_pinned(t *testing.T) {
950 repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com")

Callers

nothing calls this directly

Calls 13

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
RESTFunction · 0.92
JSONResponseFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
newTestManagerFunction · 0.85
JoinMethod · 0.80
installDirMethod · 0.80
EqualMethod · 0.80
InstallMethod · 0.65

Tested by

no test coverage detected