diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-20 08:17:31 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-20 08:17:31 +0100 |
commit | fdee09d1c0c475451eb865276dbc694c3a1beba4 (patch) | |
tree | db83ca8329c824f239569d01aed9f46572538b9e | |
parent | 08eb4731d14f8058462b9e56b891ee04d635af14 (diff) | |
download | data-service-fdee09d1c0c475451eb865276dbc694c3a1beba4.tar data-service-fdee09d1c0c475451eb865276dbc694c3a1beba4.tar.gz |
Handle when there's no system-test-data to insert
Previously it would error in one of the INSERT queries.
-rw-r--r-- | guix-data-service/model/system-test.scm | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/guix-data-service/model/system-test.scm b/guix-data-service/model/system-test.scm index 090ba58..665eff2 100644 --- a/guix-data-service/model/system-test.scm +++ b/guix-data-service/model/system-test.scm @@ -30,51 +30,52 @@ (define (insert-system-tests-for-guix-revision conn guix-revision-id system-test-data) - (let* ((system-test-ids - (insert-missing-data-and-return-all-ids - conn - "system_tests" - '(name description location_id) - (map (match-lambda - ((name description derivation-file-names-by-system location-data) - (list name - description - (location->location-id - conn - (apply location location-data))))) - system-test-data))) - (data - (append-map - (lambda (system-test-id derivation-file-names-by-system) - (let ((systems - (map car derivation-file-names-by-system)) - (derivation-ids - (derivation-file-names->derivation-ids - conn - (map cdr derivation-file-names-by-system)))) - (map (lambda (system derivation-id) - (list guix-revision-id - system-test-id - derivation-id - system)) - systems - derivation-ids))) - system-test-ids - (map third system-test-data)))) + (unless (null? system-test-data) + (let* ((system-test-ids + (insert-missing-data-and-return-all-ids + conn + "system_tests" + '(name description location_id) + (map (match-lambda + ((name description derivation-file-names-by-system location-data) + (list name + description + (location->location-id + conn + (apply location location-data))))) + system-test-data))) + (data + (append-map + (lambda (system-test-id derivation-file-names-by-system) + (let ((systems + (map car derivation-file-names-by-system)) + (derivation-ids + (derivation-file-names->derivation-ids + conn + (map cdr derivation-file-names-by-system)))) + (map (lambda (system derivation-id) + (list guix-revision-id + system-test-id + derivation-id + system)) + systems + derivation-ids))) + system-test-ids + (map third system-test-data)))) - (exec-query - conn - (string-append - " + (exec-query + conn + (string-append + " INSERT INTO guix_revision_system_test_derivations (guix_revision_id, system_test_id, derivation_id, system) VALUES " - (string-join - (map (lambda (vals) - (apply simple-format #f "(~A, ~A, ~A, '~A')" - vals)) - data) - ", ")))) + (string-join + (map (lambda (vals) + (apply simple-format #f "(~A, ~A, ~A, '~A')" + vals)) + data) + ", "))))) #t) (define (select-system-tests-for-guix-revision conn |