Source:
public void testUploadDirectoryNested() throws Exception { final Digest wobbleDigest = fakeFileCache.createScratchInput(ActionInputHelper.fromPath("bar/test/wobble"), "xyz"); final Digest quxDigest = fakeFileCache.createScratchInput(ActionInputHelper.fromPath("bar/qux"), "abc"); final Directory testDirMessage = Directory.newBuilder() .addFiles(FileNode.newBuilder().setName("wobble").setDigest(wobbleDigest).build()) .build(); final Digest testDigest = DIGEST_UTIL.compute(testDirMessage); final Tree barTree = Tree.newBuilder() .setRoot( Directory.newBuilder() .addFiles( FileNode.newBuilder() .setIsExecutable(true) .setName("qux") .setDigest(quxDigest)) .addDirectories( DirectoryNode.newBuilder().setName("test").setDigest(testDigest))) .addChildren(testDirMessage) .build(); final Digest barDigest = fakeFileCache.createScratchInputDirectory(ActionInputHelper.fromPath("bar"), barTree); final ConcurrentMap<String, byte[]> map = new ConcurrentHashMap<>(); final SimpleBlobStoreActionCache client = newClient(map); final Path quxFile = execRoot.getRelative("bar/qux"); quxFile.setExecutable(true); final Path barDir = execRoot.getRelative("bar"); ActionResult.Builder result = ActionResult.newBuilder(); Action action = Action.newBuilder().build(); ActionKey actionKey = DIGEST_UTIL.computeActionKey(action); Command cmd = Command.newBuilder().build(); client.upload(result, actionKey, action, cmd, execRoot, ImmutableList.<Path>of(barDir), true); ActionResult.Builder expectedResult = ActionResult.newBuilder(); expectedResult.addOutputDirectoriesBuilder().setPath("bar").setTreeDigest(barDigest); assertThat(result.build()).isEqualTo(expectedResult.build()); assertThat(map.keySet()) .containsAllOf(wobbleDigest.getHash(), quxDigest.getHash(), barDigest.getHash()); }

Target:
public void testUploadDirectoryNested() throws Exception { final Digest wobbleDigest = fakeFileCache.createScratchInput(ActionInputHelper.fromPath("bar/test/wobble"), "xyz"); final Digest quxDigest = fakeFileCache.createScratchInput(ActionInputHelper.fromPath("bar/qux"), "abc"); final Directory testDirMessage = Directory.newBuilder() .addFiles(FileNode.newBuilder().setName("wobble").setDigest(wobbleDigest).build()) .build(); final Digest testDigest = DIGEST_UTIL.compute(testDirMessage); final Tree barTree = Tree.newBuilder() .setRoot( Directory.newBuilder() .addFiles( FileNode.newBuilder() .setIsExecutable(true) .setName("qux") .setDigest(quxDigest)) .addDirectories( DirectoryNode.newBuilder().setName("test").setDigest(testDigest))) .addChildren(testDirMessage) .build(); final Digest barDigest = fakeFileCache.createScratchInputDirectory(ActionInputHelper.fromPath("bar"), barTree); final ConcurrentMap<String, byte[]> map = new ConcurrentHashMap<>(); final SimpleBlobStoreActionCache client = newClient(map); final Path quxFile = execRoot.getRelative("bar/qux"); quxFile.setExecutable(true); final Path barDir = execRoot.getRelative("bar"); ActionResult result = uploadDirectory(client, ImmutableList.<Path>of(barDir)); ActionResult.Builder expectedResult = ActionResult.newBuilder(); expectedResult.addOutputDirectoriesBuilder().setPath("bar").setTreeDigest(barDigest); assertThat(result).isEqualTo(expectedResult.build()); assertThat(map.keySet()) .containsAllOf(wobbleDigest.getHash(), quxDigest.getHash(), barDigest.getHash()); }