git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH JGit 1/5] adding tests for ObjectDirectory

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 21, 2009, 19:30 UTC
Message-ID
<20090921193049.GL14660@spearce.org>
In-Reply-To
<1253062116-13830-2-git-send-email-mr.gaffo@gmail.com>
mr.gaffo@gmail.com wrote:
Show 7 quoted lines
> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
> +	private File testDir;
> +
> +	@Override
> +	protected void setUp() throws Exception {
> +		testDir = new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString());
> +	}

Can't we use the same logic we use in RepositoryTestCase to create the temporary directory for this test? I would rather keep the temporary space under target/ when testing under Maven, as it makes it far easier to clean up the directory. Plus we know we have sufficient write space there.

> +	@Override
> +	protected void tearDown() throws Exception {
> +		if (testDir.exists()){
Style nit: Space between ) and {
> +	public void testExistsWithNonExistantDirectory() throws Exception {
> +		assertFalse(new ObjectDirectory(new File("/some/nonexistant/file")).exists());

Please create a path name below your testDir which you know won't exist. I don't want this test to rely upon the fact that some absolute path doesn't exist that is outside of our namespace control.

> +	private void createTestDir(){

You use this method once, inline it inside testExistsWithExistingDirectory().

Otherwise, the test case is OK, but is still quite sparse with regards to functionality of the class being tested. Was it your intention to only cover the most basic parts at this time? Its more coverage than we have now, so I'm happy, but just wanted to point out it certainly isn't complete (e.g. no pack support).

-- 
Shawn.
Previous: Michael Gaffney
Message 12 of 12 in “Adding update-server-info functionality try2”
  1. Adding update-server-info functionality try2mr.gaffo@gmail.com, Sep 16, 2009
  2. 1/5 adding tests for ObjectDirectorymr.gaffo@gmail.com, Sep 16, 2009
  3. 2/5 Create abstract method on ObjectDatabase for accessing the list of local pack files.mr.gaffo@gmail.com, Sep 16, 2009
  4. 3/5 Implemented directory based info cache for objects/info/packs.mr.gaffo@gmail.com, Sep 16, 2009
  5. 4/5 Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory.mr.gaffo@gmail.com, Sep 16, 2009
  6. 5/5 added tests for the file based info cache update and made passmr.gaffo@gmail.com, Sep 16, 2009
  7. Shawn O. PearceOct 8, 2009
  8. Shawn O. PearceOct 8, 2009
  9. Shawn O. PearceOct 8, 2009
  10. Shawn O. PearceSep 21, 2009
  11. Michael GaffneySep 21, 2009
  12. Shawn O. PearceSep 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.