diff options
author | Mathieu Othacehe <m.othacehe@gmail.com> | 2018-04-19 11:17:42 +0200 |
---|---|---|
committer | Mathieu Othacehe <m.othacehe@gmail.com> | 2018-04-19 11:17:42 +0200 |
commit | c40e61bd3e9c4d1ceca53002c7bc21ff0754cfff (patch) | |
tree | 7fe7a78cfa153afeb5e44cd4e6a976e8bac0d220 /tests | |
parent | 238f856e48ee333ed3e19fa32ce5e1742c650c67 (diff) | |
download | cuirass-c40e61bd3e9c4d1ceca53002c7bc21ff0754cfff.tar cuirass-c40e61bd3e9c4d1ceca53002c7bc21ff0754cfff.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/http.scm | 28 |
1 files changed, 25 insertions, 3 deletions
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))) |