(t *testing.T)
| 901 | } |
| 902 | |
| 903 | func 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: ®} |
| 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 | |
| 949 | func TestManager_Install_binary_pinned(t *testing.T) { |
| 950 | repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com") |
nothing calls this directly
no test coverage detected