(t *testing.T)
| 977 | } |
| 978 | |
| 979 | func TestManager_Install_git_pinned(t *testing.T) { |
| 980 | dataDir := t.TempDir() |
| 981 | updateDir := t.TempDir() |
| 982 | |
| 983 | reg := httpmock.Registry{} |
| 984 | defer reg.Verify(t) |
| 985 | client := http.Client{Transport: ®} |
| 986 | |
| 987 | ios, _, stdout, stderr := iostreams.Test() |
| 988 | |
| 989 | extensionDir := filepath.Join(dataDir, "extensions", "gh-cool-ext") |
| 990 | gc, gcOne := &mockGitClient{}, &mockGitClient{} |
| 991 | gc.On("ForRepo", extensionDir).Return(gcOne).Once() |
| 992 | gc.On("Clone", "https://github.com/owner/gh-cool-ext.git", []string{extensionDir}).Return("", nil).Once() |
| 993 | gcOne.On("CheckoutBranch", "abcd1234").Return(nil).Once() |
| 994 | |
| 995 | m := newTestManager(dataDir, updateDir, &client, gc, ios) |
| 996 | |
| 997 | reg.Register( |
| 998 | httpmock.REST("GET", "repos/owner/gh-cool-ext/releases/latest"), |
| 999 | httpmock.JSONResponse( |
| 1000 | release{ |
| 1001 | Assets: []releaseAsset{ |
| 1002 | { |
| 1003 | Name: "not-a-binary", |
| 1004 | APIURL: "https://example.com/release/cool", |
| 1005 | }, |
| 1006 | }, |
| 1007 | })) |
| 1008 | reg.Register( |
| 1009 | httpmock.REST("GET", "repos/owner/gh-cool-ext/commits/some-ref"), |
| 1010 | httpmock.StringResponse("abcd1234")) |
| 1011 | reg.Register( |
| 1012 | httpmock.REST("GET", "repos/owner/gh-cool-ext/contents/gh-cool-ext"), |
| 1013 | httpmock.JSONResponse(map[string]string{"type": "file"})) |
| 1014 | |
| 1015 | _ = os.MkdirAll(filepath.Join(m.installDir(), "gh-cool-ext"), 0700) |
| 1016 | repo := ghrepo.New("owner", "gh-cool-ext") |
| 1017 | err := m.Install(repo, "some-ref") |
| 1018 | assert.NoError(t, err) |
| 1019 | assert.Equal(t, "", stderr.String()) |
| 1020 | assert.Equal(t, "", stdout.String()) |
| 1021 | gc.AssertExpectations(t) |
| 1022 | gcOne.AssertExpectations(t) |
| 1023 | } |
| 1024 | |
| 1025 | func TestManager_Install_binary_pinned(t *testing.T) { |
| 1026 | repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com") |
nothing calls this directly
no test coverage detected