From 85e4133e17892aa07b3b06871bd46451c1d32f0c Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 3 Aug 2026 09:32:07 +0900 Subject: tests: Add new json-utils tests. * tests/json-utils.scm ("add-json-fields", "add-json-fields, recursive") ("add-json-fields, recursive, partially preexisting"): New tests. --- tests/json-utils.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/json-utils.scm b/tests/json-utils.scm index 30f63774345..3e33d182d3a 100644 --- a/tests/json-utils.scm +++ b/tests/json-utils.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2026 Nicolas Graves +;;; Copyright © 2026 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -160,6 +161,31 @@ captures the written output as a string." (fresh-sample-json)))) (equal? (assoc-ref result "name") "my-package"))) +;;; +;;; add-json-fields +;;; +(test-equal "add-json-fields" + #("test") + (assoc-ref (modify-json* + (add-json-fields '(("exclude" . #("test"))))) + "exclude")) + +(test-equal "add-json-fields, recursive" + "^25.9.2" + (assoc-ref (assoc-ref (modify-json* + (add-json-fields '(("devDependencies2.@types/node" + . "^25.9.2")))) + "devDependencies2") + "@types/node")) + +(test-equal "add-json-fields, recursive, partially preexisting" + "^9.9.9" + (assoc-ref (assoc-ref (modify-json* + (add-json-fields '(("devDependencies.@types/dummy" + . "^9.9.9")))) + "devDependencies") + "@types/dummy")) + ;;; ;;; modify-json-fields ;;; -- cgit v1.2.3