refactor(config): 重构 AppPaths 的构造方法, 应对将来 Kotlin 更新中的特性.

先前的方法是利用了初始化与调用的顺序, 来实现的 Supplier 互补(虽然在代码中, 确实存在未初始化调用的情况, 但实际运行的时候, 会先初始化, 再调用 Supplier),
但是未来 Kotlin 的更新中,编译器会把这个操作视为未初始化错误, 所以在这次改动中修复掉这个 bug 操作.
This commit is contained in:
2022-08-15 01:38:08 +08:00
parent dce28be9c7
commit 255a02c93c
2 changed files with 51 additions and 10 deletions

View File

@ -21,6 +21,17 @@ import kotlin.test.*
internal class AppPathsTest {
@Test
fun `Consistency check`() {
for (path in AppPaths.values()) {
assertEquals(
File(path.path).canonicalPath,
path.file.canonicalPath,
"路径 File 与 Path 不一致: ${path.name}"
)
}
}
@Test
fun `Data root path priority`() {
System.setProperty(AppPaths.PathConst.PROP_DATA_PATH, "fromSystemProperties")