mirror of
https://github.com/apple/pkl.git
synced 2026-05-03 21:54:19 +02:00
Require global settings file to use pkl:settings (#477)
This is technically a breaking change, but follows the intended use-case and documentation of settings. * Require that the global settings file at `~/.pkl/settings.pkl` amends stdlib module `pkl:settings`, or otherwise sets `output.value` to an instance of `pkl.Settings`. * Simplify the object mapping of `PklSettings.java`
This commit is contained in:
@@ -2,6 +2,7 @@ package org.pkl.core.settings
|
||||
|
||||
import java.nio.file.Path
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatCode
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import org.pkl.commons.createParentDirectories
|
||||
@@ -67,6 +68,13 @@ class PklSettingsTest {
|
||||
checkEquals(Editor.VS_CODE, module.getProperty("vsCode") as PObject)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `invalid settings file`(@TempDir tempDir: Path) {
|
||||
val settingsFile = tempDir.resolve("settings.pkl").apply { writeString("foo = 1") }
|
||||
assertThatCode { PklSettings.loadFromPklHomeDir(tempDir) }
|
||||
.hasMessageContaining("Expected `output.value` of module `${settingsFile.toUri()}` to be of type `pkl.settings`, but got type `settings`.")
|
||||
}
|
||||
|
||||
private fun checkEquals(expected: Editor, actual: PObject) {
|
||||
assertThat(actual.getProperty("urlScheme") as String).isEqualTo(expected.urlScheme)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user