Skip to content

Commit

Permalink
fix(fork): Test rewriting
Browse files Browse the repository at this point in the history
Still fails.
  • Loading branch information
gounthar committed Dec 10, 2024
1 parent f961ac3 commit ec41545
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ public PagedIterable<GHRepository> listForks(final ForkSort sort) {
* @return Newly forked repository that belong to you.
* @throws IOException
* the io exception
* @deprecated
* @deprecated
*/
@Deprecated
public GHRepository fork() throws IOException {
Expand Down Expand Up @@ -1491,7 +1491,7 @@ public GHBranchSync sync(String branch) throws IOException {
* @return Newly forked repository that belong to you.
* @throws IOException
* the io exception
* @deprecated
* @deprecated
*/
@Deprecated
public GHRepository forkTo(GHOrganization org) throws IOException {
Expand Down Expand Up @@ -1535,7 +1535,8 @@ public GHRepository createFork(String organization, String name, boolean default

// this API is asynchronous. we need to wait for a bit
for (int i = 0; i < 10; i++) {
GHRepository r = organization != null ? root().getOrganization(organization).getRepository(name != null ? name : this.name)
GHRepository r = organization != null
? root().getOrganization(organization).getRepository(name != null ? name : this.name)
: root().getMyself().getRepository(name != null ? name : this.name);
if (r != null) {
return r;
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/kohsuke/github/GitHubWireMockRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ protected void before() {
.stubFor(any(anyUrl()).willReturn(aResponse().withTransformers(ProxyToOriginalHostTransformer.NAME))
.atPriority(100));
}

this.apiServer()
.stubFor(post(urlMatching("/repos/.*/forks")).willReturn(aResponse().withStatus(202)
.withHeader("Content-Type", "application/json")
.withBodyFile("fork.json")));

this.apiServer()
.stubFor(get(urlMatching("/repos/hub4j-test-org/github-api")).willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("repository.json")));
}

/**
Expand Down

0 comments on commit ec41545

Please sign in to comment.