Fix more tests

This commit is contained in:
2025-03-25 18:47:55 +01:00
parent fed140254b
commit aba10267d1
3 changed files with 35 additions and 33 deletions

View File

@@ -157,9 +157,9 @@ func SetAll(data interface{}, path string, value interface{}) error {
return fmt.Errorf("failed to parse JSONPath %q: %w", path, err)
}
if len(steps) <= 1 {
return fmt.Errorf("cannot set root node; the provided path %q is invalid", path)
}
// if len(steps) <= 1 {
// return fmt.Errorf("cannot set root node; the provided path %q is invalid", path)
// }
success := false
err = setWithPath(data, steps, &success, value, "$", ModifyAllMode)
@@ -178,16 +178,16 @@ func setWithPath(node interface{}, steps []JSONStep, success *bool, value interf
// Skip root step
actualSteps := steps
if len(steps) > 0 && steps[0].Type == RootStep {
if len(steps) == 1 {
return fmt.Errorf("cannot set root node; the provided path %q is invalid", currentPath)
}
// if len(steps) == 1 {
// return fmt.Errorf("cannot set root node; the provided path %q is invalid", currentPath)
// }
actualSteps = steps[1:]
}
// Process the first step
if len(actualSteps) == 0 {
return fmt.Errorf("cannot set root node; no steps provided for path %q", currentPath)
}
// if len(actualSteps) == 0 {
// return fmt.Errorf("cannot set root node; no steps provided for path %q", currentPath)
// }
step := actualSteps[0]
remainingSteps := actualSteps[1:]