Search in sources :

Example 1 with RepositoryCache

use of com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache in project bazel by bazelbuild.

the class MavenJarFunctionTest method testNoSha1WithCache.

@Test
public void testNoSha1WithCache() throws Exception {
    Rule rule = scratchRule("external", "foo", "maven_jar(", "    name = 'foo',", "    artifact = 'x:y:z:1.1',", ")");
    RepositoryCache cache = Mockito.mock(RepositoryCache.class);
    Mockito.when(cache.isEnabled()).thenReturn(true);
    MavenDownloader downloader = new MavenDownloader(cache);
    try {
        downloader.download("foo", WorkspaceAttributeMapper.of(rule), scratch.dir("/whatever"), TEST_SERVER);
        fail("Expected failure to fetch artifact because of nonexistent server.");
    } catch (IOException expected) {
        assertThat(expected.getMessage()).contains("Failed to fetch Maven dependency:");
    }
}
Also used : RepositoryCache(com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache) Rule(com.google.devtools.build.lib.packages.Rule) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

RepositoryCache (com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache)1 Rule (com.google.devtools.build.lib.packages.Rule)1 IOException (java.io.IOException)1 Test (org.junit.Test)1