Skip to content

Commit

Permalink
Test cases related to JENKINS-21434 - alternates file wrong content
Browse files Browse the repository at this point in the history
Checks that cloned copies have the alternates file with expected
content when the clone is performed with a reference repository, and
that cloned copies do not have the alternates file when clone does not
use a reference repository.
  • Loading branch information
MarkEWaite committed Jan 21, 2014
1 parent 6d50b04 commit a7df8d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
Expand Up @@ -246,6 +246,8 @@ public void test_clone() throws IOException, InterruptedException
}
check_remote_url("origin");
check_branches("master");
final String alternates = ".git" + File.separator + "objects" + File.separator + "info" + File.separator + "alternates";
assertFalse("Alternates file found: " + alternates, w.exists(alternates));
}

public void test_clone_repositoryName() throws IOException, InterruptedException
Expand All @@ -257,6 +259,8 @@ public void test_clone_repositoryName() throws IOException, InterruptedException
}
check_remote_url("upstream");
check_branches("master");
final String alternates = ".git" + File.separator + "objects" + File.separator + "info" + File.separator + "alternates";
assertFalse("Alternates file found: " + alternates, w.exists(alternates));
}

public void test_clone_shallow() throws IOException, InterruptedException
Expand All @@ -268,6 +272,8 @@ public void test_clone_shallow() throws IOException, InterruptedException
}
check_remote_url("origin");
check_branches("master");
final String alternates = ".git" + File.separator + "objects" + File.separator + "info" + File.separator + "alternates";
assertFalse("Alternates file found: " + alternates, w.exists(alternates));
}

/** shared is not implemented in CliGitAPIImpl. */
Expand All @@ -292,6 +298,16 @@ public void test_clone_reference() throws IOException, InterruptedException
}
check_remote_url("origin");
check_branches("master");
final String alternates = ".git" + File.separator + "objects" + File.separator + "info" + File.separator + "alternates";
if (w.git instanceof CliGitAPIImpl) {
assertTrue("Alternates file not found: " + alternates, w.exists(alternates));
final String expectedContent = localMirror().replace("\\", "/") + "/objects";
final String actualContent = w.contentOf(alternates).trim(); // Remove trailing line terminator(s)
assertEquals("Alternates file wrong content", expectedContent, actualContent);
} else {
/* JGit does not implement reference cloning yet */
assertFalse("Alternates file found: " + alternates, w.exists(alternates));
}
}

public void test_detect_commit_in_repo() throws Exception {
Expand Down

0 comments on commit a7df8d7

Please sign in to comment.