use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseRepoJobTest method testExecuteHasMethodInQueueNewRepository.
public void testExecuteHasMethodInQueueNewRepository() throws JobExecutionException {
SharedService sharedServiceMock = mock(SharedService.class);
when(sharedServiceMock.getPauseBackgroundJobs()).thenReturn(false);
when(sharedServiceMock.getBackgroundJobsEnabled()).thenReturn(true);
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob(sharedServiceMock);
IndexGitRepoJob spy = spy(indexGitRepoJob);
spy.haveRepoResult = false;
UniqueRepoQueue uniqueRepoQueue = new UniqueRepoQueue();
uniqueRepoQueue.add(new RepoResult(1, "name", "scm", "url", "username", "password", "source", "branch", "{}"));
when(spy.getNextQueuedRepo()).thenReturn(uniqueRepoQueue);
when(spy.isEnabled()).thenReturn(true);
when(spy.getNewRepository(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean())).thenReturn(new RepositoryChanged(false, null, null));
when(mockCodeIndexer.shouldPauseAdding()).thenReturn(false);
spy.codeIndexer = mockCodeIndexer;
spy.execute(this.mockContext);
assertThat(spy.haveRepoResult).isTrue();
assertThat(spy.LOWMEMORY).isTrue();
verify(spy).getNextQueuedRepo();
verify(spy, times(2)).getNewRepository(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean());
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseRepoJobTest method testGetCodeLinesLogNotIndexedInvalid.
public void testGetCodeLinesLogNotIndexedInvalid() {
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
indexGitRepoJob.LOGINDEXED = false;
List<String[]> reportList = new ArrayList<>();
IndexBaseRepoJob.CodeLinesReturn codeLines = indexGitRepoJob.getCodeLines("", reportList);
assertThat(codeLines.isError()).isTrue();
assertThat(codeLines.getReportList().isEmpty()).isTrue();
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testGetBlameFilePath.
public void testGetBlameFilePath() {
IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
String actual = gitRepoJob.getBlameFilePath("./repo/something/test");
assertEquals("repo/something/test", actual);
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testMissingPathFilesShouldPage.
public void testMissingPathFilesShouldPage() {
IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
CodeSearcher codeSearcherMock = Mockito.mock(CodeSearcher.class);
List<String> repoReturn = new ArrayList<>();
for (int i = 0; i < 10; i++) {
repoReturn.add("string" + i);
}
when(codeSearcherMock.getRepoDocuments("testRepoName", 0)).thenReturn(repoReturn);
when(codeSearcherMock.getRepoDocuments("testRepoName", 1)).thenReturn(repoReturn);
when(codeSearcherMock.getRepoDocuments("testRepoName", 2)).thenReturn(new ArrayList<>());
gitRepoJob.cleanMissingPathFiles(codeSearcherMock, "testRepoName", new HashMap<String, String>());
verify(codeSearcherMock, times(1)).getRepoDocuments("testRepoName", 0);
verify(codeSearcherMock, times(1)).getRepoDocuments("testRepoName", 1);
verify(codeSearcherMock, times(1)).getRepoDocuments("testRepoName", 2);
}
use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.
the class IndexBaseAndGitRepoJobTest method testIndexSucess.
public void testIndexSucess() throws IOException {
IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
File baseDir = new File(System.getProperty("java.io.tmpdir"));
File tempDir = new File(baseDir, "testIndexSucess");
if (tempDir.exists()) {
FileUtils.deleteDirectory(tempDir);
}
tempDir.mkdir();
String tempDirString = tempDir.toString();
assertFalse(gitRepoJob.checkIndexSucess(tempDirString));
gitRepoJob.createIndexSuccess(tempDirString);
assertTrue(gitRepoJob.checkIndexSucess(tempDirString));
gitRepoJob.deleteIndexSuccess(tempDirString);
assertFalse(gitRepoJob.checkIndexSucess(tempDirString));
}
Aggregations