From bf1f26a52bf487deffc5892427131bc5ba56b4e3 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Tue, 31 Mar 2026 19:17:03 +0000 Subject: [PATCH] test(builtins): add spec tests for jq --arg/--argjson field assignment Add tests covering the exact examples from the issue: field assignment with --arg, --argjson with numeric values, and dynamic key access with --arg. The feature was already implemented; these tests ensure coverage. Closes #914 --- crates/bashkit/tests/spec_cases/jq/jq.test.sh | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/bashkit/tests/spec_cases/jq/jq.test.sh b/crates/bashkit/tests/spec_cases/jq/jq.test.sh index 0e142c0a..2795cdd4 100644 --- a/crates/bashkit/tests/spec_cases/jq/jq.test.sh +++ b/crates/bashkit/tests/spec_cases/jq/jq.test.sh @@ -933,6 +933,33 @@ jq -n --argjson obj '{"a":1}' '$obj.a' 1 ### end +### jq_arg_field_assignment +# --arg with field assignment using herestring +jq --arg name "John" '.greeting = "Hello " + $name' <<< '{}' +### expect +{ + "greeting": "Hello John" +} +### end + +### jq_argjson_field_assignment +# --argjson with numeric field assignment +jq --argjson count 42 '.total = $count' <<< '{}' +### expect +{ + "total": 42 +} +### end + +### jq_arg_dynamic_key +# --arg with dynamic key using .[$key] +jq --arg key "name" --arg val "Alice" '.[$key] = $val' <<< '{}' +### expect +{ + "name": "Alice" +} +### end + ### jq_combined_flags_snr # Three combined short flags -snr jq -snr '"hello"'