diff --git a/Makefile.am b/Makefile.am index ae4e6c8..bb72285 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 = \ diff --git a/src/cuirass/utils.scm b/src/cuirass/utils.scm index e087050..45f8f1e 100644 --- a/src/cuirass/utils.scm +++ b/src/cuirass/utils.scm @@ -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 diff --git a/tests/http.scm b/tests/http.scm index 3bf52d2..fdb0f8a 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -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!) diff --git a/tests/utils.scm b/tests/utils.scm deleted file mode 100644 index d5298c5..0000000 --- a/tests/utils.scm +++ /dev/null @@ -1,38 +0,0 @@ -;;;; utils.scm -- tests for (cuirass utils) module -;;; -;;; Copyright © 2016 Mathieu Lirzin -;;; -;;; 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 . - -(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)