Accept ConfigKit integers in module options
This commit is contained in:
@@ -155,7 +155,7 @@ func nonNegativeIntOption(name string, value any) (int, error) {
|
||||
}
|
||||
|
||||
func intOption(name string, value any) (int, error) {
|
||||
got, ok := value.(int)
|
||||
got, ok := pipeline.IntOption(value)
|
||||
if !ok {
|
||||
return 0, chunkerErrorf("%s must be an integer", name)
|
||||
}
|
||||
|
||||
@@ -121,9 +121,19 @@ func TestPlanRejectsInvalidOptions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeOptionsRejectsNonNativeIntegers(t *testing.T) {
|
||||
func TestDecodeOptionsAcceptsConfigKitIntegers(t *testing.T) {
|
||||
options, err := DecodeOptions(map[string]any{"max_units": int64(2), "overlap_units": int64(1)})
|
||||
if err != nil {
|
||||
t.Fatalf("DecodeOptions() error = %v", err)
|
||||
}
|
||||
if options.MaxUnits != 2 || options.OverlapUnits != 1 {
|
||||
t.Fatalf("DecodeOptions() = %#v", options)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeOptionsRejectsUnsupportedIntegerRepresentations(t *testing.T) {
|
||||
for _, value := range []any{
|
||||
int8(2), int16(2), int32(2), int64(2),
|
||||
int8(2), int16(2), int32(2),
|
||||
uint(2), uint8(2), uint16(2), uint32(2), uint64(2),
|
||||
float32(2), float64(2), json.Number("2"),
|
||||
} {
|
||||
|
||||
Reference in New Issue
Block a user