Search in sources :

Example 6 with IndexGitRepoJob

use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.

the class IndexBaseAndGitRepoJobTest method testDeleteNoFile.

public void testDeleteNoFile() 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();
    for (int i = 0; i < 100; i++) {
        gitRepoJob.deleteIndexSuccess(tempDirString);
        gitRepoJob.deleteCloneUpdateSuccess(tempDirString);
    }
}
Also used : File(java.io.File) IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob)

Example 7 with IndexGitRepoJob

use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.

the class IndexBaseAndGitRepoJobTest method testGetRelativeToProjectPath.

public void testGetRelativeToProjectPath() {
    IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
    String relativeToProjectPath = gitRepoJob.getRelativeToProjectPath("/Users/boyter/test5", "/Users/boyter/test5/u/something/sources/small/c3p0.csv");
    assertThat(relativeToProjectPath).isEqualTo("/u/something/sources/small/c3p0.csv");
    relativeToProjectPath = gitRepoJob.getRelativeToProjectPath("/Users/boyter/test5/", "/Users/boyter/test5/u/something/sources/small/c3p0.csv");
    assertThat(relativeToProjectPath).isEqualTo("/u/something/sources/small/c3p0.csv");
    relativeToProjectPath = gitRepoJob.getRelativeToProjectPath("./repo/test", "./repo/test/chinese.php");
    assertThat(relativeToProjectPath).isEqualTo("/chinese.php");
    relativeToProjectPath = gitRepoJob.getRelativeToProjectPath("./repo/test/", "./repo/test/chinese.php");
    assertThat(relativeToProjectPath).isEqualTo("/chinese.php");
    relativeToProjectPath = gitRepoJob.getRelativeToProjectPath("./repo/test", "./repo//test/chinese.php");
    assertThat(relativeToProjectPath).isEqualTo("/chinese.php");
}
Also used : IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob)

Example 8 with IndexGitRepoJob

use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.

the class IndexBaseAndGitRepoJobTest method testDetermineBinary.

public void testDetermineBinary() {
    IndexGitRepoJob gitRepoJob = new IndexGitRepoJob();
    gitRepoJob.LOGINDEXED = true;
    List<String[]> reportList = new ArrayList<>();
    boolean result = gitRepoJob.determineBinary("", "", new ArrayList<>(), reportList);
    assertThat(result).isTrue();
    assertThat(reportList.size()).isEqualTo(1);
}
Also used : ArrayList(java.util.ArrayList) IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob)

Example 9 with IndexGitRepoJob

use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.

the class IndexBaseAndGitRepoJobTest method testCheckCloneSuccessEmptyReturnsFalse.

public void testCheckCloneSuccessEmptyReturnsFalse() {
    IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
    boolean actual = indexGitRepoJob.checkCloneSuccess("", "");
    assertThat(actual).isFalse();
}
Also used : IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob)

Example 10 with IndexGitRepoJob

use of com.searchcode.app.jobs.repository.IndexGitRepoJob in project searchcode-server by boyter.

the class IndexBaseRepoJobTest method testExecuteNothingInQueue.

public void testExecuteNothingInQueue() throws JobExecutionException {
    IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
    IndexGitRepoJob spy = spy(indexGitRepoJob);
    spy.haveRepoResult = false;
    when(spy.getNextQueuedRepo()).thenReturn(new UniqueRepoQueue());
    spy.codeIndexer = mockCodeIndexer;
    spy.execute(this.mockContext);
    assertThat(spy.haveRepoResult).isFalse();
}
Also used : IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob) UniqueRepoQueue(com.searchcode.app.util.UniqueRepoQueue)

Aggregations

IndexGitRepoJob (com.searchcode.app.jobs.repository.IndexGitRepoJob)21 ArrayList (java.util.ArrayList)5 CodeSearcher (com.searchcode.app.service.CodeSearcher)4 File (java.io.File)4 RepositoryChanged (com.searchcode.app.dto.RepositoryChanged)3 IndexBaseRepoJob (com.searchcode.app.jobs.repository.IndexBaseRepoJob)3 SearchResult (com.searchcode.app.dto.SearchResult)2 UniqueRepoQueue (com.searchcode.app.util.UniqueRepoQueue)2 Path (java.nio.file.Path)2 TestHelpers (com.searchcode.app.TestHelpers)1 Values (com.searchcode.app.config.Values)1 CodeResult (com.searchcode.app.dto.CodeResult)1 IndexFileRepoJob (com.searchcode.app.jobs.repository.IndexFileRepoJob)1 IndexSvnRepoJob (com.searchcode.app.jobs.repository.IndexSvnRepoJob)1 RepoResult (com.searchcode.app.model.RepoResult)1 CodeIndexer (com.searchcode.app.service.CodeIndexer)1 SharedService (com.searchcode.app.service.SharedService)1 Singleton (com.searchcode.app.service.Singleton)1 StatsService (com.searchcode.app.service.StatsService)1 Properties (com.searchcode.app.util.Properties)1