Add testCleanDirsWithSubmodule test to CleanCommandTest
This commit adds some test coverage to cleaning a repository with a submodule, which did not previously exist. Bug: 498367 Change-Id: Ia5c4e4cc53488800dd486f8556dc57656783f1c4 Signed-off-by: Matthaus Owens <matthaus@puppetlabs.com>
This commit is contained in:
parent
23b1405484
commit
0ee89f01be
|
@ -45,6 +45,7 @@
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.eclipse.jgit.lib.Constants.DOT_GIT_MODULES;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -52,6 +53,7 @@
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.errors.NoWorkTreeException;
|
import org.eclipse.jgit.errors.NoWorkTreeException;
|
||||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||||
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -227,4 +229,30 @@ public void testCleanDirsWithDryRunAndNoIgnore()
|
||||||
assertTrue(cleanedFiles.contains("ignored-dir/"));
|
assertTrue(cleanedFiles.contains("ignored-dir/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanDirsWithSubmodule() throws Exception {
|
||||||
|
SubmoduleAddCommand command = new SubmoduleAddCommand(db);
|
||||||
|
String path = "sub";
|
||||||
|
command.setPath(path);
|
||||||
|
String uri = db.getDirectory().toURI().toString();
|
||||||
|
command.setURI(uri);
|
||||||
|
Repository repo = command.call();
|
||||||
|
repo.close();
|
||||||
|
|
||||||
|
Status beforeCleanStatus = git.status().call();
|
||||||
|
assertTrue(beforeCleanStatus.getAdded().contains(DOT_GIT_MODULES));
|
||||||
|
assertTrue(beforeCleanStatus.getAdded().contains(path));
|
||||||
|
|
||||||
|
Set<String> cleanedFiles = git.clean().setCleanDirectories(true).call();
|
||||||
|
|
||||||
|
// The submodule should not be cleaned.
|
||||||
|
assertTrue(!cleanedFiles.contains(path + "/"));
|
||||||
|
|
||||||
|
assertTrue(cleanedFiles.contains("File2.txt"));
|
||||||
|
assertTrue(cleanedFiles.contains("File3.txt"));
|
||||||
|
assertTrue(!cleanedFiles.contains("sub-noclean/File1.txt"));
|
||||||
|
assertTrue(cleanedFiles.contains("sub-noclean/File2.txt"));
|
||||||
|
assertTrue(cleanedFiles.contains("sub-clean/"));
|
||||||
|
assertTrue(cleanedFiles.size() == 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue