package org.shedlang.compiler.config; import org.junit.jupiter.api.Test; import org.shedlang.compiler.config.json.Json5ObjectWithSource; import org.shedlang.compiler.sources.SourceTexts; import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.*; public class ProfileConfigTests { @Test public void canParseProfileConfigWithName() { var source = """ { name: "one", } """; var config = parseProfileConfig(source); assertThat(config, has("name", x -> x.name(), equalTo("one"))); } @Test public void canParseProfileConfigWithoutGc() { var source = """ { name: "one", } """; var config = parseProfileConfig(source); assertThat(config, has("name", x -> x.gc(), isOptionalEmpty())); } @Test public void canParseProfileConfigWithGc() { var source = """ { name: "one", gc: { "name": "bump", }, } """; var config = parseProfileConfig(source); assertThat(config, has( "gc", x -> x.gc(), isOptionalOf(equalTo(GcConfig.BUMP)) )); } private ProfileConfig parseProfileConfig(String text) { var sourceText = SourceTexts.string(text); return ProfileConfig.fromJson5(Json5ObjectWithSource.parse(sourceText)); } }