use of com.facebook.eden.thrift.SHA1Result in project buck by facebook.
the class EdenMountTest method getSha1DelegatesToThriftClient.
@Test
public void getSha1DelegatesToThriftClient() throws EdenError, TException {
List<MountInfo> mountInfos = ImmutableList.of(new MountInfo("/home/mbolin/src/buck", /* edenClientPath */
""));
EdenService.Client thriftClient = createMock(EdenService.Client.class);
expect(thriftClient.listMounts()).andReturn(mountInfos);
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path entry = fs.getPath("LICENSE");
HashCode hash = HashCode.fromString("2b8b815229aa8a61e483fb4ba0588b8b6c491890");
SHA1Result sha1Result = new SHA1Result();
sha1Result.setSha1(hash.asBytes());
expect(thriftClient.getSHA1("/home/mbolin/src/buck", ImmutableList.of("LICENSE"))).andReturn(ImmutableList.of(sha1Result));
replay(thriftClient);
EdenClient client = new EdenClient(thriftClient);
Path pathToBuck = fs.getPath("/home/mbolin/src/buck");
EdenMount mount = client.getMountFor(pathToBuck);
assertNotNull("Should find mount for path.", mount);
assertEquals(Sha1HashCode.fromHashCode(hash), mount.getSha1(entry));
verify(thriftClient);
}
use of com.facebook.eden.thrift.SHA1Result in project buck by facebook.
the class EdenMount method getSha1.
/**
* @param entry is a path that is relative to {@link #getProjectRoot()}.
*/
public Sha1HashCode getSha1(Path entry) throws EdenError, TException {
List<SHA1Result> results = client.get().getSHA1(mountPoint, ImmutableList.of(normalizePathArg(entry)));
SHA1Result result = Iterables.getOnlyElement(results);
if (result.getSetField() == SHA1Result.SHA1) {
return Sha1HashCode.fromBytes(result.getSha1());
} else {
throw result.getError();
}
}
Aggregations