Skip to content

Commit a52d946

Browse files
committed
refactor: reorganize test structure with directory-based organization
- Reorganize tests into logical directories: basic/, predicates/, extended/, scenarios/, compatibility/, benchmarks/ - Move individual operation tests to appropriate directories maintaining granular testing - Split advanced predicates into separate files (and_test.go, or_test.go, not_test.go) - Consolidate benchmark tests into single benchmarks/ directory - Create unified testutils library for consistent test patterns - Remove "advanced" prefixes and simplify naming conventions - Fix all linting issues and ensure code formatting consistency - Maintain all existing test functionality while improving organization
1 parent a0aba7f commit a52d946

36 files changed

+1452
-209
lines changed

codec/json/decode.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ func OperationToOp(operation map[string]interface{}, options internal.JSONPatchO
9797
case "flip":
9898
return op.NewOpFlipOperation(path), nil
9999
case "inc":
100-
incVal, ok := op.ToFloat64(operation["inc"])
101-
if !ok {
100+
incField, hasInc := operation["inc"]
101+
if !hasInc {
102102
return nil, ErrIncOpMissingInc
103103
}
104+
incVal, ok := op.ToFloat64(incField)
105+
if !ok {
106+
return nil, ErrIncOpInvalidType
107+
}
104108
return op.NewOpIncOperation(path, incVal), nil
105109
case "str_ins":
106110
pos, ok := op.ToFloat64(operation["pos"])

codec/json/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var (
1515

1616
// ErrIncOpMissingInc indicates inc operation is missing 'inc' field
1717
ErrIncOpMissingInc = errors.New("inc operation missing 'inc' field")
18+
// ErrIncOpInvalidType indicates inc operation 'inc' field must be a number
19+
ErrIncOpInvalidType = errors.New("inc operation 'inc' field must be a number")
1820
// ErrStrInsOpMissingPos indicates str_ins operation is missing 'pos' field
1921
ErrStrInsOpMissingPos = errors.New("str_ins operation missing 'pos' field")
2022
// ErrStrInsOpMissingStr indicates str_ins operation is missing 'str' field
File renamed without changes.

0 commit comments

Comments
 (0)