assertThat(fs.provider()).isInstanceOf(JimfsFileSystemProvider.class);
}
@Test
public void testFileStore() throws IOException {
FileStore fileStore = Iterables.getOnlyElement(fs.getFileStores());
assertThat(fileStore.name()).isEqualTo("jimfs");
assertThat(fileStore.type()).isEqualTo("jimfs");
assertThat(fileStore.isReadOnly()).isFalse();
long totalSpace = 1024 * 1024 * 1024; // 1 GB
assertThat(fileStore.getTotalSpace()).isEqualTo(totalSpace);
assertThat(fileStore.getUnallocatedSpace()).isEqualTo(totalSpace);
assertThat(fileStore.getUsableSpace()).isEqualTo(totalSpace);
Files.write(fs.getPath("/foo"), new byte[10000]);
assertThat(fileStore.getTotalSpace()).isEqualTo(totalSpace);
// We wrote 10000 bytes, but since the file system allocates fixed size blocks, more than 10k
// bytes may have been allocated. As such, the unallocated space after the write can be at most
// maxUnallocatedSpace.
assertThat(fileStore.getUnallocatedSpace() <= totalSpace - 10000).isTrue();
// Usable space is at most unallocated space. (In this case, it's currently exactly unallocated
// space, but that's not required.)
assertThat(fileStore.getUsableSpace() <= fileStore.getUnallocatedSpace()).isTrue();
Files.delete(fs.getPath("/foo"));
assertThat(fileStore.getTotalSpace()).isEqualTo(totalSpace);
assertThat(fileStore.getUnallocatedSpace()).isEqualTo(totalSpace);
assertThat(fileStore.getUsableSpace()).isEqualTo(totalSpace);
}