Search in sources :

Example 6 with RepositoryRevisionCache

use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.

the class RevisionsCacheTest method get_repo_cache_by_dir.

public void get_repo_cache_by_dir() throws Exception {
    RepositoryRevisionCache repoCache1 = myCache.getRepositoryCache(repository("1"), RevisionCacheType.COMMIT_CACHE);
    RepositoryRevisionCache repoCache2 = myCache.getRepositoryCache(repository("2"), RevisionCacheType.COMMIT_CACHE);
    then(repoCache1).isNotNull();
    then(repoCache2).isNotNull();
    then(repoCache1).isNotSameAs(repoCache2);
    then(repoCache1).isSameAs(myCache.getRepositoryCache(repository("1"), RevisionCacheType.COMMIT_CACHE));
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache)

Example 7 with RepositoryRevisionCache

use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.

the class RevisionsCacheTest method save_revision_entry.

public void save_revision_entry() throws Exception {
    File repo = repository("1");
    RepositoryRevisionCache commitCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
    commitCache.saveRevision("v1", false, commitCache.getResetCounter());
    commitCache.saveRevision("v2", true, commitCache.getResetCounter());
    commitCache.saveRevision("v3", false, commitCache.getResetCounter());
    then(commitCache.hasRevision("v1")).isFalse();
    then(commitCache.hasRevision("v2")).isTrue();
    then(commitCache.hasRevision("v3")).isFalse();
    then(commitCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Example 8 with RepositoryRevisionCache

use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.

the class RevisionsCacheTest method save_revision_entry_different_types.

public void save_revision_entry_different_types() throws Exception {
    File repo = repository("1");
    RepositoryRevisionCache commitCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
    RepositoryRevisionCache hintCache = myCache.getRepositoryCache(repo, RevisionCacheType.HINT_CACHE);
    commitCache.saveRevision("v1", false, commitCache.getResetCounter());
    hintCache.saveRevision("v2", true, hintCache.getResetCounter());
    then(commitCache.hasRevision("v1")).isFalse();
    then(commitCache.hasRevision("v2")).isNull();
    then(hintCache.hasRevision("v1")).isNull();
    then(hintCache.hasRevision("v2")).isTrue();
    then(commitCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
    then(hintCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.HINT_CACHE));
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Example 9 with RepositoryRevisionCache

use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.

the class RevisionsCacheTest method should_write_empty_cache.

public void should_write_empty_cache() throws Exception {
    File repo = repository("1");
    RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
    repoCache.saveRevision("v1", false, repoCache.getResetCounter());
    myCache.resetNegativeEntries(repo);
    then(repoCache).isEqualTo(new RevisionsCache(myConfig).getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE));
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) RevisionsCache(jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache) File(java.io.File)

Example 10 with RepositoryRevisionCache

use of jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache in project teamcity-git by JetBrains.

the class RevisionsCacheTest method should_write_to_disk_only_if_cache_was_updated.

public void should_write_to_disk_only_if_cache_was_updated() throws Exception {
    File repo = repository("1");
    RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
    File cacheFile = RepositoryRevisionCache.getCacheFile(repo, RevisionCacheType.COMMIT_CACHE);
    repoCache.saveRevision("v1", true, repoCache.getResetCounter());
    then(cacheFile).exists();
    FileUtil.delete(cacheFile);
    repoCache.saveRevision("v1", true, repoCache.getResetCounter());
    then(cacheFile).doesNotExist();
    myCache.resetNegativeEntries(repo);
    then(cacheFile).doesNotExist();
    myCache.resetNegativeEntries(repo, setOf("v2"));
    then(cacheFile).doesNotExist();
}
Also used : RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) File(java.io.File)

Aggregations

RepositoryRevisionCache (jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache)17 File (java.io.File)15 RevisionsCache (jetbrains.buildServer.buildTriggers.vcs.git.RevisionsCache)9 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 RevisionCacheType (jetbrains.buildServer.buildTriggers.vcs.git.RevisionCacheType)2 Test (org.testng.annotations.Test)2 Semaphore (java.util.concurrent.Semaphore)1 ServerPluginConfig (jetbrains.buildServer.buildTriggers.vcs.git.ServerPluginConfig)1 TestFor (jetbrains.buildServer.util.TestFor)1