branch: main commit 11ed407a5abbc57cca0492805f7f7872f9d0c08b Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Fri Aug 30 17:23:13 2024 +0200
http: /admin/specification/add converts channel name to a symbol. * src/cuirass/http.scm (body->specification): Convert channel name to a symbol. * tests/http.scm ("/admin/specification/add"): New test. --- src/cuirass/http.scm | 2 +- tests/http.scm | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 27cf18f..db6c1ab 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -459,7 +459,7 @@ into a specification record and return it." param))))))) (channels (map (lambda (name url branch) (channel - (name name) + (name (string->symbol name)) (url url) (branch branch))) (filter-field 'channel-name) diff --git a/tests/http.scm b/tests/http.scm index bdd2b7d..837c2bf 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -387,7 +387,48 @@ (json-string->scm (utf8->string (http-get-body - (test-cuirass-uri "/api/jobs/history?spec=guix&names=fake-job&nr=10")))))) + (test-cuirass-uri + "/api/jobs/history?spec=guix&names=fake-job&nr=10")))))) + + (test-equal "/admin/specification/add" + `(dynamically-added ("aarch64-linux" "x86_64-linux") + system-tests + 7777 1 + ((guix "http://example.org/guix" "main") + (whatever "http://example.org/whatever" "main"))) + (begin + ;; Create a jobset via a POST request and ensure it then appears in the + ;; database. + (http-post (test-cuirass-uri "/admin/specification/add") + #:body (string-append "name=dynamically-added&" + "build=system-tests&" + "channel-name=guix&" + "channel-url=" + (uri-encode "http://example.org/guix") + "&" + "channel-branch=main&" + "channel-name=whatever&" + "channel-url=" + (uri-encode + "http://example.org/whatever") + "&" + "channel-branch=main&" + "x86_64-linux=1&aarch64-linux=1&" + "period=7777&priority=1")) + (and (= 200 + (response-code + (http-get (test-cuirass-uri "/jobset/dynamically-added")))) + (let ((spec (db-get-specification 'dynamically-added))) + (list (specification-name spec) + (specification-systems spec) + (specification-build spec) + (specification-period spec) + (specification-priority spec) + (map (lambda (channel) + (list (channel-name channel) + (channel-url channel) + (channel-branch channel))) + (specification-channels spec))))))) (test-equal "/admin/gitlab/event creates a spec from a new merge request" (specification-name mr-spec)