MCPcopy Create free account
hub / github.com/cli/cli / TestForkRepoReturnsErrorWhenForkIsNotPossible

Function TestForkRepoReturnsErrorWhenForkIsNotPossible

api/queries_repo_test.go:934–959  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

932}
933
934func TestForkRepoReturnsErrorWhenForkIsNotPossible(t *testing.T) {
935 // Given our API returns 202 with a Fork that is the same as
936 // the repo we provided
937 repoName := "test-repo"
938 ownerLogin := "test-owner"
939 stubbedForkResponse := repositoryV3{
940 Name: repoName,
941 Owner: struct{ Login string }{
942 Login: ownerLogin,
943 },
944 }
945
946 reg := &httpmock.Registry{}
947 reg.Register(
948 httpmock.REST("POST", fmt.Sprintf("repos/%s/%s/forks", ownerLogin, repoName)),
949 httpmock.StatusJSONResponse(202, stubbedForkResponse),
950 )
951
952 client := newTestClient(reg)
953
954 // When we fork the repo
955 _, err := ForkRepo(client, ghrepo.New(ownerLogin, repoName), ownerLogin, "", false)
956
957 // Then it provides a useful error message
958 require.Equal(t, fmt.Errorf("%s/%s cannot be forked. A single user account cannot own both a parent and fork.", ownerLogin, repoName), err)
959}
960
961func TestListLicenseTemplatesReturnsLicenses(t *testing.T) {
962 hostname := "api.github.com"

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
RESTFunction · 0.92
StatusJSONResponseFunction · 0.92
NewFunction · 0.92
newTestClientFunction · 0.85
ForkRepoFunction · 0.85
EqualMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected