From d3913a14d55968e505429693a6df6125e3468300 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 4 Sep 2019 19:24:22 +0200 Subject: Start handling ids as numbers, rather than strings squee, returns all data as strings, and expects strings as inputs to queries. So, keeping the ids as strings was easy initially, but it means that you can't tell from the type whether it should be quoted, or not... Therefore, handle ids as strings, converting them to numbers when they're fetched from the database, and back to strings as part of the queries. --- tests/model-git-repository.scm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/model-git-repository.scm') diff --git a/tests/model-git-repository.scm b/tests/model-git-repository.scm index befcbfa..ee72f24 100644 --- a/tests/model-git-repository.scm +++ b/tests/model-git-repository.scm @@ -1,4 +1,5 @@ (define-module (test-model-git-repository) + #:use-module (ice-9 match) #:use-module (srfi srfi-64) #:use-module (guix-data-service database) #:use-module (guix-data-service model git-repository)) @@ -12,22 +13,21 @@ (with-postgresql-transaction conn (lambda (conn) - (number? - (string->number - (git-repository-url->git-repository-id - conn - "test-non-existent-url")))) + (match (git-repository-url->git-repository-id + conn + "test-non-existent-url") + ((? number? x) + #t))) #:always-rollback? #t)) - (test-assert "returns the right id for an existing URL" + (let* ((url "test-url") + (id (git-repository-url->git-repository-id conn url))) (with-postgresql-transaction conn (lambda (conn) - (let* ((url "test-url") - (id (git-repository-url->git-repository-id conn url))) - (string=? - id - (git-repository-url->git-repository-id conn url)))) + (test-equal "returns the right id for an existing URL" + id + (git-repository-url->git-repository-id conn url))) #:always-rollback? #t)))) (test-end) -- cgit v1.2.3