package configkit_test import ( "testing" configkit "gitea.maximumdirect.net/eric/ConfigKit" ) func TestFacadeInactiveContextsPreserveClosedFailure(t *testing.T) { t.Parallel() for _, state := range []struct { name string resolution *configkit.Resolution validation *configkit.Validation }{ {name: "nil"}, {name: "zero", resolution: &configkit.Resolution{}, validation: &configkit.Validation{}}, } { t.Run(state.name, func(t *testing.T) { path := configkit.Keys("value") var target int for _, operation := range []struct { name string call func() }{ {"IsExplicit", func() { state.resolution.IsExplicit(path) }}, {"InputInfo", func() { state.resolution.InputInfo(path) }}, {"Source", func() { state.resolution.Source("source") }}, {"Record", func() { state.resolution.Record(path, configkit.ChangeNormalization, "reason") }}, {"Resolution.Error", func() { state.resolution.Error(path, "message") }}, {"Resolution.Warning", func() { state.resolution.Warning(path, "message") }}, {"Default", func() { configkit.Default(state.resolution, path, &target, 1, "reason") }}, {"Normalize", func() { configkit.Normalize(state.resolution, path, &target, 1, "reason") }}, {"Validation.Error", func() { state.validation.Error(path, "message") }}, {"Validation.Warning", func() { state.validation.Warning(path, "message") }}, } { t.Run(operation.name, func(t *testing.T) { defer func() { if got := recover(); got != "configkit: callback context is no longer active" { t.Errorf("panic = %v; want fixed closed-context failure", got) } if target != 0 { t.Error("inactive helper changed target") } }() operation.call() }) } }) } }