(t *testing.T)
| 821 | } |
| 822 | |
| 823 | func TestManager_Install_git(t *testing.T) { |
| 824 | dataDir := t.TempDir() |
| 825 | updateDir := t.TempDir() |
| 826 | |
| 827 | reg := httpmock.Registry{} |
| 828 | defer reg.Verify(t) |
| 829 | client := http.Client{Transport: ®} |
| 830 | |
| 831 | ios, _, stdout, stderr := iostreams.Test() |
| 832 | |
| 833 | fakeExtensionName := "gh-some-ext" |
| 834 | extensionDir := filepath.Join(dataDir, "extensions", fakeExtensionName) |
| 835 | gc := &mockGitClient{} |
| 836 | gc.On("Clone", "https://github.com/owner/gh-some-ext.git", []string{extensionDir}).Return("", nil).Once() |
| 837 | |
| 838 | // Create a temporary directory to simulate the local extension update state |
| 839 | extensionUpdatePath := filepath.Join(updateDir, fakeExtensionName) |
| 840 | require.NoError(t, stubExtensionUpdate(extensionUpdatePath)) |
| 841 | |
| 842 | m := newTestManager(dataDir, updateDir, &client, gc, ios) |
| 843 | |
| 844 | reg.Register( |
| 845 | httpmock.REST("GET", "repos/owner/gh-some-ext/releases/latest"), |
| 846 | httpmock.JSONResponse( |
| 847 | release{ |
| 848 | Assets: []releaseAsset{ |
| 849 | { |
| 850 | Name: "not-a-binary", |
| 851 | APIURL: "https://example.com/release/cool", |
| 852 | }, |
| 853 | }, |
| 854 | })) |
| 855 | reg.Register( |
| 856 | httpmock.REST("GET", "repos/owner/gh-some-ext/contents/gh-some-ext"), |
| 857 | httpmock.StringResponse("script")) |
| 858 | |
| 859 | repo := ghrepo.New("owner", fakeExtensionName) |
| 860 | |
| 861 | err := m.Install(repo, "") |
| 862 | assert.NoError(t, err) |
| 863 | assert.Equal(t, "", stdout.String()) |
| 864 | assert.Equal(t, "", stderr.String()) |
| 865 | gc.AssertExpectations(t) |
| 866 | |
| 867 | assert.NoDirExistsf(t, extensionUpdatePath, "update directory should be removed") |
| 868 | } |
| 869 | |
| 870 | func TestManager_Install_not_installable(t *testing.T) { |
| 871 | dataDir := t.TempDir() |
nothing calls this directly
no test coverage detected