Accept ConfigKit integers in module options
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
units "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/chunk/units"
|
||||
jsonoutput "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/output/json"
|
||||
)
|
||||
|
||||
func TestLoadedConfigConvertsDocumentsAndResolvesRuntimePipeline(t *testing.T) {
|
||||
@@ -91,6 +93,40 @@ pipelines:
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadedConfigPreservesConfigKitIntegerOptionsForModules(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5
|
||||
pipelines:
|
||||
session:
|
||||
input: {module: input}
|
||||
chunk:
|
||||
module: generic
|
||||
options:
|
||||
max_units: 3
|
||||
overlap_units: 1
|
||||
output:
|
||||
module: json
|
||||
options:
|
||||
evidence_context:
|
||||
enabled: true
|
||||
lanes: [score]
|
||||
window_units: 2
|
||||
`)), LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("loadConfigSource() error = %v", err)
|
||||
}
|
||||
profile := loaded.Config.Pipelines["session"]
|
||||
chunkOptions, err := units.DecodeOptions(profile.Chunk.Options)
|
||||
if err != nil || chunkOptions.MaxUnits != 3 || chunkOptions.OverlapUnits != 1 {
|
||||
t.Fatalf("chunk options = %#v, %v", chunkOptions, err)
|
||||
}
|
||||
outputOptions, err := jsonoutput.DecodeOptions(profile.Output.Options)
|
||||
if err != nil || !outputOptions.EvidenceContext.Enabled || outputOptions.EvidenceContext.WindowUnits != 2 {
|
||||
t.Fatalf("output options = %#v, %v", outputOptions, err)
|
||||
}
|
||||
}
|
||||
|
||||
func pipelineProfileWithChangedOption(profile pipeline.PipelineProfile) pipeline.PipelineProfile {
|
||||
profile = clonePipelineProfile(profile)
|
||||
nested := profile.Artifacts["score"].Extract.Options["nested"].(map[string]any)
|
||||
|
||||
Reference in New Issue
Block a user