utils: Remove now useless 'object->json-string' & co.

* src/cuirass/utils.scm (alist?, object->json-scm)
(object->json-string): Remove.
* tests/utils.scm: Remove.
* Makefile.am (TESTS): Remove it.
* tests/http.scm ("object->json-string"): Remove.
This commit is contained in:
Ludovic Courtès 2023-08-23 16:00:24 +02:00
parent 77bf78ecf7
commit 931597826a
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
4 changed files with 2 additions and 90 deletions

View File

@ -158,8 +158,7 @@ TESTS = \
tests/database.scm \
tests/http.scm \
tests/metrics.scm \
tests/remote.scm \
tests/utils.scm
tests/remote.scm
# Compiler warning flags.
GUILE_WARNINGS = \

View File

@ -27,13 +27,9 @@
#:use-module (system foreign)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (json)
#:use-module (fibers)
#:use-module (fibers channels)
#:export (alist?
object->json-scm
object->json-string
define-enumeration
#:export (define-enumeration
make-resource-pool
with-resource-from-pool
@ -46,30 +42,6 @@
random-string
call-with-time))
(define (alist? obj)
"Return #t if OBJ is an alist."
(and (list? obj)
(every pair? obj)))
(define (object->json-scm obj)
"Prepare OBJ for JSON usage."
(cond ((string? obj) obj)
((number? obj) obj)
((boolean? obj) obj)
((null? obj) obj)
((symbol? obj) (symbol->string obj))
((keyword? obj) (object->json-scm (keyword->symbol obj)))
((vector? obj) (list->vector
(map object->json-scm (vector->list obj))))
((alist? obj) (map object->json-scm obj))
((pair? obj) (cons (object->json-scm (car obj))
(object->json-scm (cdr obj))))
(else (object->string obj))))
(define* (object->json-string object #:key pretty)
"Return OBJECT as a JSON object."
(scm->json-string (object->json-scm object) #:pretty pretty))
(define-syntax-rule (define-enumeration name (symbol value) ...)
"Define an 'enum' type with the given SYMBOL/VALUE pairs. NAME is defined a
macro that accepts one of these symbols and expands to the corresponding

View File

@ -83,27 +83,6 @@
(directory . "dir3")))))))
(test-group-with-cleanup "http"
(test-assert "object->json-string"
(lset= equal?
(call-with-input-string
(string-append "{"
"\"boolean\" : false,"
"\"string\" : \"guix\","
"\"alist\" : {\"subset\" : \"hello\"},"
"\"list\" : [1, \"2\", \"three\"],"
"\"symbol\" : \"hydra-jobs\","
"\"number\" : 1"
"}")
json->scm)
(call-with-input-string
(object->json-string '((#:number . 1)
(string . "guix")
("symbol" . hydra-jobs)
(#:alist . ((subset . "hello")))
(list . #(1 "2" #:three))
("boolean" . #f)))
json->scm)))
(test-assert "db-init"
(begin
(test-init-db!)

View File

@ -1,38 +0,0 @@
;;;; utils.scm -- tests for (cuirass utils) module
;;;
;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
;;;
;;; This file is part of Cuirass.
;;;
;;; Cuirass is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Cuirass is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>.
(use-modules (cuirass utils)
(srfi srfi-64))
(define dir-1 (make-parameter ""))
(define dir-2 (make-parameter ""))
(test-begin "utils")
(test-assert "alist?"
(and (alist? '())
(alist? '(("foo" 1 2)))
(alist? '(("foo" . 1)
("bar" . 2)))
(not (alist? 3))
(not (alist? '(1 2 3)))
(not (alist? 'foo))
(not (alist? #:bar))))
(test-end)