Implement Set and SetAll (and Get)
This commit is contained in:
@@ -158,12 +158,7 @@ func TestEvaluator(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
steps, err := ParseJSONPath(tt.path)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse error: %v", err)
|
||||
}
|
||||
|
||||
result := EvaluateJSONPath(testData, steps)
|
||||
result := Get(testData, tt.path)
|
||||
|
||||
// Special handling for wildcard recursive test
|
||||
if tt.name == "wildcard_recursive" {
|
||||
@@ -187,18 +182,13 @@ func TestEvaluator(t *testing.T) {
|
||||
t.Errorf("Expected %v, got %v", tt.expected, resultItem)
|
||||
}
|
||||
}
|
||||
|
||||
// if !reflect.DeepEqual(result, tt.expected) {
|
||||
// t.Errorf("EvaluateJSONPath() = %v, want %v", result, tt.expected)
|
||||
// }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEdgeCases(t *testing.T) {
|
||||
t.Run("empty_data", func(t *testing.T) {
|
||||
steps, _ := ParseJSONPath("$.a.b")
|
||||
result := EvaluateJSONPath(nil, steps)
|
||||
result := Get(nil, "$.a.b")
|
||||
if len(result) > 0 {
|
||||
t.Errorf("Expected empty result, got %v", result)
|
||||
}
|
||||
@@ -215,9 +205,8 @@ func TestEdgeCases(t *testing.T) {
|
||||
data := map[string]interface{}{
|
||||
"42": "answer",
|
||||
}
|
||||
steps, _ := ParseJSONPath("$.42")
|
||||
result := EvaluateJSONPath(data, steps)
|
||||
if result[0] != "answer" {
|
||||
result := Get(data, "$.42")
|
||||
if len(result) == 0 || result[0] != "answer" {
|
||||
t.Errorf("Expected 'answer', got %v", result)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user