fun <T : Path> Expect<T>.notToBeWritable(): Expect<T>
(source)
Expects that the subject of this
expectation (a Path) is not writable;
meaning that there is a file system entry at the location the Path points to and
that the current thread does not have the permission to write to it.
This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.
assertIf(ifPosixSupported) {
val readyOnlyPermissions =
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--r--r--"))
val readyWritePermissions =
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--"))
val readOnlyDir = tempDir.newDirectory("read_only_dir", readyOnlyPermissions)
val readOnlyFile = tempDir.newFile("read_only_file", readyOnlyPermissions)
val readWriteDir = tempDir.newDirectory("read_write_dir", readyWritePermissions)
val readWriteFile = tempDir.newFile("read_write_file", readyWritePermissions)
expect(readOnlyDir).notToBeWritable()
expect(readOnlyFile).notToBeWritable()
fails {
expect(readWriteDir).notToBeWritable()
}
fails {
expect(readWriteFile).notToBeWritable()
}
}
fails {
expect(Paths.get("non_existing_dir")).notToBeWritable()
}
Return
an Expect for the subject of this
expectation.
Since
0.17.0