To make tests faster and more reliable, swap FileSystem.SYSTEM with FakeFileSystem. This allows you to manipulate a virtual file system in memory without actual disk I/O. You can also use ForwardingFileSystem to inject faults (like simulating a full disk) to test error handling.
val fileSystem = FakeFileSystem()
val userHome = "/Users/sandy".toPath()
val gitConfig = userHome / ".gitconfig"
fileSystem.createDirectories(userHome)
val original = """
|[user]
| email = sandy@example.com
|".trimMargin()
fileSystem.write(gitConfig) { writeUtf8(original) }
// Example usage with a hypothetical fixer
GitConfigFixer(fileSystem).fix(userHome)
val expected = """
|[user]
| email = sandy@example.com
|[diff]
| renames = true
| indentHeuristic = on
|".trimIndent()
assertEquals(expected, fileSystem.read(gitConfig) { readUtf8() })