From c40e61bd3e9c4d1ceca53002c7bc21ff0754cfff Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Thu, 19 Apr 2018 11:17:42 +0200 Subject: http: Add /api/evaluations route. * src/cuirass/database.scm (db-get-evaluations): New exported procedure. * src/cuirass/http.scm (url-handler): Add /api/evaluations route. * tests/http.scm ("http"): Add /api/evaluations test route. --- tests/http.scm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'tests/http.scm') diff --git a/tests/http.scm b/tests/http.scm index 1e1f754..9d460b2 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -94,6 +94,11 @@ (#:releasename . #nil) (#:buildinputs_builds . #nil))) +(define evaluations-query-result + '((#:id . 2) + (#:specification . "guix") + (#:revision . "fakesha2"))) + (test-group-with-cleanup "http" (test-assert "object->json-string" ;; Note: We cannot compare the strings directly because field ordering @@ -175,15 +180,19 @@ (#:tag . #f) (#:commit . #f) (#:no-compile? . #f))) - (evaluation + (evaluation1 + '((#:specification . "guix") + (#:revision . "fakesha1"))) + (evaluation2 '((#:specification . "guix") - (#:revision . 1)))) + (#:revision . "fakesha2")))) (db-add-build (%db) build1) (db-add-build (%db) build2) (db-add-derivation (%db) derivation1) (db-add-derivation (%db) derivation2) (db-add-specification (%db) specification) - (db-add-evaluation (%db) evaluation))) + (db-add-evaluation (%db) evaluation1) + (db-add-evaluation (%db) evaluation2))) (test-assert "/build/1" (hash-table=? @@ -254,6 +263,19 @@ (list (hash-ref dictionary "nixname") (hash-ref dictionary "buildstatus"))))) + (test-assert "/api/evaluations?nr=1" + (let ((hash-list + (call-with-input-string + (utf8->string + (http-get-body (test-cuirass-uri "/api/evaluations?nr=1"))) + json->scm))) + (and (= (length hash-list) 1) + (hash-table=? + (car hash-list) + (call-with-input-string + (object->json-string evaluations-query-result) + json->scm))))) + (test-assert "db-close" (db-close (%db))) -- cgit v1.2.3