(t *testing.T)
| 897 | } |
| 898 | |
| 899 | func TestManager_Install_git(t *testing.T) { |
| 900 | dataDir := t.TempDir() |
| 901 | updateDir := t.TempDir() |
| 902 | |
| 903 | reg := httpmock.Registry{} |
| 904 | defer reg.Verify(t) |
| 905 | client := http.Client{Transport: ®} |
| 906 | |
| 907 | ios, _, stdout, stderr := iostreams.Test() |
| 908 | |
| 909 | fakeExtensionName := "gh-some-ext" |
| 910 | extensionDir := filepath.Join(dataDir, "extensions", fakeExtensionName) |
| 911 | gc := &mockGitClient{} |
| 912 | gc.On("Clone", "https://github.com/owner/gh-some-ext.git", []string{extensionDir}).Return("", nil).Once() |
| 913 | |
| 914 | // Create a temporary directory to simulate the local extension update state |
| 915 | extensionUpdatePath := filepath.Join(updateDir, fakeExtensionName) |
| 916 | require.NoError(t, stubExtensionUpdate(extensionUpdatePath)) |
| 917 | |
| 918 | m := newTestManager(dataDir, updateDir, &client, gc, ios) |
| 919 | |
| 920 | reg.Register( |
| 921 | httpmock.REST("GET", "repos/owner/gh-some-ext/releases/latest"), |
| 922 | httpmock.JSONResponse( |
| 923 | release{ |
| 924 | Assets: []releaseAsset{ |
| 925 | { |
| 926 | Name: "not-a-binary", |
| 927 | APIURL: "https://example.com/release/cool", |
| 928 | }, |
| 929 | }, |
| 930 | })) |
| 931 | reg.Register( |
| 932 | httpmock.REST("GET", "repos/owner/gh-some-ext/contents/gh-some-ext"), |
| 933 | httpmock.JSONResponse(map[string]string{"type": "file"})) |
| 934 | |
| 935 | repo := ghrepo.New("owner", fakeExtensionName) |
| 936 | |
| 937 | err := m.Install(repo, "") |
| 938 | assert.NoError(t, err) |
| 939 | assert.Equal(t, "", stdout.String()) |
| 940 | assert.Equal(t, "", stderr.String()) |
| 941 | gc.AssertExpectations(t) |
| 942 | |
| 943 | assert.NoDirExistsf(t, extensionUpdatePath, "update directory should be removed") |
| 944 | } |
| 945 | |
| 946 | func TestManager_Install_not_installable(t *testing.T) { |
| 947 | dataDir := t.TempDir() |
nothing calls this directly
no test coverage detected