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