use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.
the class GitOriginTest method testNoChange.
@Test
public void testNoChange() throws Exception {
// This is needed to initialize the local repo
origin.resolve(firstCommitRef);
CannotResolveRevisionException thrown = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve("foo"));
assertThat(thrown).hasMessageThat().contains("Cannot find reference(s): [foo, refs/tags/*]");
}
use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.
the class HgRepositoryTest method testIdentify.
@Test
public void testIdentify() throws Exception {
addAndCommitFile("foo");
ImmutableList<HgLogEntry> commits = repository.log().run();
String globalId = commits.get(0).getGlobalId();
for (String reference : ImmutableList.of(globalId, "tip", String.valueOf(0), "default")) {
HgRevision revision = repository.identify(reference);
assertThat(revision.getGlobalId()).isEqualTo(globalId);
assertThat(revision.contextReference()).isEqualTo(reference);
}
CannotResolveRevisionException expected = assertThrows(CannotResolveRevisionException.class, () -> repository.identify("not_a_branch"));
assertThat(expected.getMessage()).contains("Unknown revision");
}
use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.
the class HgOriginTest method testResolveNullOrEmptyReferenceNoSourceRef.
@Test
public void testResolveNullOrEmptyReferenceNoSourceRef() throws Exception {
origin = skylark.eval("result", String.format("result = hg.origin(\n" + " url = '%s', \n" + " ref = '')", url));
CannotResolveRevisionException expected1 = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve(null));
assertThat(expected1.getMessage()).isEqualTo("No source reference was passed through the" + " command line and the default reference is empty");
CannotResolveRevisionException expected2 = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve(""));
assertThat(expected2.getMessage()).isEqualTo("No source reference was passed through the" + " command line and the default reference is empty");
}
Aggregations