(t *testing.T)
| 921 | } |
| 922 | |
| 923 | func TestForkRepoReturnsErrorWhenForkIsNotPossible(t *testing.T) { |
| 924 | // Given our API returns 202 with a Fork that is the same as |
| 925 | // the repo we provided |
| 926 | repoName := "test-repo" |
| 927 | ownerLogin := "test-owner" |
| 928 | stubbedForkResponse := repositoryV3{ |
| 929 | Name: repoName, |
| 930 | Owner: struct{ Login string }{ |
| 931 | Login: ownerLogin, |
| 932 | }, |
| 933 | } |
| 934 | |
| 935 | reg := &httpmock.Registry{} |
| 936 | reg.Register( |
| 937 | httpmock.REST("POST", fmt.Sprintf("repos/%s/%s/forks", ownerLogin, repoName)), |
| 938 | httpmock.StatusJSONResponse(202, stubbedForkResponse), |
| 939 | ) |
| 940 | |
| 941 | client := newTestClient(reg) |
| 942 | |
| 943 | // When we fork the repo |
| 944 | _, err := ForkRepo(client, ghrepo.New(ownerLogin, repoName), ownerLogin, "", false) |
| 945 | |
| 946 | // Then it provides a useful error message |
| 947 | require.Equal(t, fmt.Errorf("%s/%s cannot be forked. A single user account cannot own both a parent and fork.", ownerLogin, repoName), err) |
| 948 | } |
| 949 | |
| 950 | func TestListLicenseTemplatesReturnsLicenses(t *testing.T) { |
| 951 | hostname := "api.github.com" |
nothing calls this directly
no test coverage detected