(t *testing.T)
| 824 | } |
| 825 | |
| 826 | func TestForkRepoReturnsErrorWhenForkIsNotPossible(t *testing.T) { |
| 827 | // Given our API returns 202 with a Fork that is the same as |
| 828 | // the repo we provided |
| 829 | repoName := "test-repo" |
| 830 | ownerLogin := "test-owner" |
| 831 | stubbedForkResponse := repositoryV3{ |
| 832 | Name: repoName, |
| 833 | Owner: struct{ Login string }{ |
| 834 | Login: ownerLogin, |
| 835 | }, |
| 836 | } |
| 837 | |
| 838 | reg := &httpmock.Registry{} |
| 839 | reg.Register( |
| 840 | httpmock.REST("POST", fmt.Sprintf("repos/%s/%s/forks", ownerLogin, repoName)), |
| 841 | httpmock.StatusJSONResponse(202, stubbedForkResponse), |
| 842 | ) |
| 843 | |
| 844 | client := newTestClient(reg) |
| 845 | |
| 846 | // When we fork the repo |
| 847 | _, err := ForkRepo(client, ghrepo.New(ownerLogin, repoName), ownerLogin, "", false) |
| 848 | |
| 849 | // Then it provides a useful error message |
| 850 | require.Equal(t, fmt.Errorf("%s/%s cannot be forked. A single user account cannot own both a parent and fork.", ownerLogin, repoName), err) |
| 851 | } |
| 852 | |
| 853 | func TestListLicenseTemplatesReturnsLicenses(t *testing.T) { |
| 854 | hostname := "api.github.com" |
nothing calls this directly
no test coverage detected