use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseRepoJobTest method testGetMinified.
public void testGetMinified() {
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
indexGitRepoJob.LOGINDEXED = true;
List<String[]> reportList = new ArrayList<>();
IndexBaseRepoJob.IsMinifiedReturn isMinified = indexGitRepoJob.getIsMinified(new ArrayList<>(), "", reportList);
assertThat(isMinified.isMinified()).isFalse();
assertThat(isMinified.getReportList().isEmpty()).isTrue();
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testShouldJobTerminate.
public void testShouldJobTerminate() {
IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
StatsService statsServiceMock = Mockito.mock(StatsService.class);
when(statsServiceMock.getLoadAverage()).thenReturn("0.0");
Singleton.setStatsService(statsServiceMock);
assertThat(gitRepoJob.shouldJobPauseOrTerminate()).isFalse();
Singleton.getSharedService().setBackgroundJobsEnabled(false);
assertThat(gitRepoJob.shouldJobPauseOrTerminate()).isTrue();
Singleton.getSharedService().setBackgroundJobsEnabled(true);
assertThat(gitRepoJob.shouldJobPauseOrTerminate()).isFalse();
Singleton.getSharedService().setPauseBackgroundJobs(true);
Singleton.getSharedService().setBackgroundJobsEnabled(false);
assertThat(gitRepoJob.shouldJobPauseOrTerminate()).isTrue();
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testCheckCloneSuccessEmptyReturnsTrue.
public void testCheckCloneSuccessEmptyReturnsTrue() throws IOException {
File location = TestHelpers.clearAndCreateTempPath("testCheckCloneSuccessEmptyReturnsTrue");
File projectLocation = TestHelpers.createDirectory(location, "myawesomeproject");
TestHelpers.createFile(projectLocation, "myfile.java", "some file content");
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
boolean actual = indexGitRepoJob.checkCloneSuccess("myawesomeproject", location.getAbsolutePath());
assertThat(actual).isTrue();
File toCheck = new File(projectLocation.getAbsolutePath());
assertThat(toCheck.exists()).isFalse();
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testGetFileLocationFilename.
public void testGetFileLocationFilename() {
IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
String fileLocationFilename = gitRepoJob.getFileLocationFilename(".git/filename", "./repo/");
assertThat(fileLocationFilename).isEqualTo(".git/filename");
fileLocationFilename = gitRepoJob.getFileLocationFilename("./repo/.git/filename", "./repo/");
assertThat(fileLocationFilename).isEqualTo(".git/filename");
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class EndToEndITCase method testEndToEndGitDelta.
public void testEndToEndGitDelta() throws IOException {
CodeSearcher cs = new CodeSearcher();
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
File directoryWithFiles = TestHelpers.createDirectoryWithFiles("EndToEndGitTest");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "init", ".");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "add", ".");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "commit", "-m", "\"First commit\"");
// Clone from the above into a new directory
File tempPath = TestHelpers.clearAndCreateTempPath("EndToEndGitCloneTest");
this.runCommand(tempPath.toString(), this.GITPATH, "clone", directoryWithFiles.toString(), "EndToEndGitTest");
// Index
indexGitRepoJob.indexDocsByPath(Paths.get(tempPath.toString()), "EndToEndGitTest", "", tempPath.toString(), false);
SearchResult searchResult = cs.search("endtoendtestfile", 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(3);
// Update the source
TestHelpers.createFile(directoryWithFiles, "EndToEndTestFile4.cpp", "EndToEndTestFile EndToEndTestFile4");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "add", ".");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "commit", "-m", "\"Add new\"");
// Index and lets dance
RepositoryChanged repositoryChanged = indexGitRepoJob.updateExistingRepository("EndToEndGitTest", "repoRemoteLocation", "", "", tempPath.toString(), "", false);
String repoGitLocation = tempPath.toString() + "/" + "EndToEndGitTest";
Path docDir = Paths.get(repoGitLocation);
indexGitRepoJob.indexDocsByDelta(docDir, "EndToEndGitTest", tempPath.toString(), "", repositoryChanged);
searchResult = cs.search("endtoendtestfile", 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(4);
// Update the source
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "rm", "EndToEndTestFile4.cpp");
this.runCommand(directoryWithFiles.toString(), this.GITPATH, "commit", "-m", "\"Baleted\"");
// Index and lets dance
repositoryChanged = indexGitRepoJob.updateExistingRepository("EndToEndGitTest", "repoRemoteLocation", "", "", tempPath.toString(), "", false);
repoGitLocation = tempPath.toString() + "/" + "EndToEndGitTest";
docDir = Paths.get(repoGitLocation);
indexGitRepoJob.indexDocsByDelta(docDir, "EndToEndGitTest", tempPath.toString(), "", repositoryChanged);
searchResult = cs.search("endtoendtestfile", 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(3);
Singleton.getCodeIndexer().deleteByReponame("EndToEndGitTest");
searchResult = cs.search("endtoendtestfile".toLowerCase(), 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(0);
}
Aggregations