aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/database.scm31
-rw-r--r--tests/http.scm55
2 files changed, 56 insertions, 30 deletions
diff --git a/tests/database.scm b/tests/database.scm
index cdc7872..21a12f4 100644
--- a/tests/database.scm
+++ b/tests/database.scm
@@ -47,9 +47,13 @@
(#:commit . #f)
(#:no-compile? . #f))))))
-(define* (make-dummy-eval #:optional (commits '("cabba3e 61730ea")))
- `((#:specification . "guix")
- (#:commits . ,commits)))
+(define (make-dummy-checkouts fakesha1 fakesha2)
+ `(((#:commit . ,fakesha1)
+ (#:input . "guix")
+ (#:directory . "foo"))
+ ((#:commit . ,fakesha2)
+ (#:input . "packages")
+ (#:directory . "bar"))))
(define* (make-dummy-build drv
#:optional (eval-id 42)
@@ -88,11 +92,11 @@
(test-assert "sqlite-exec"
(begin
(sqlite-exec (%db) "\
-INSERT INTO Evaluations (specification, commits) VALUES (1, 1);")
+INSERT INTO Evaluations (specification, in_progress) VALUES (1, false);")
(sqlite-exec (%db) "\
-INSERT INTO Evaluations (specification, commits) VALUES (2, 2);")
+INSERT INTO Evaluations (specification, in_progress) VALUES (2, false);")
(sqlite-exec (%db) "\
-INSERT INTO Evaluations (specification, commits) VALUES (3, 3);")
+INSERT INTO Evaluations (specification, in_progress) VALUES (3, false);")
(sqlite-exec (%db) "SELECT * FROM Evaluations;")))
(test-equal "db-add-specification"
@@ -121,7 +125,8 @@ INSERT INTO Evaluations (specification, commits) VALUES (3, 3);")
#:outputs '(("out" . "/foo")))))
(get-status (lambda* (#:optional (key #:status))
(assq-ref (db-get-build derivation) key))))
- (db-add-evaluation (make-dummy-eval))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakesha1"
+ "fakesha2"))
(db-add-specification example-spec)
(let ((status0 (get-status)))
@@ -157,9 +162,9 @@ INSERT INTO Evaluations (specification, commits) VALUES (3, 3);")
#:outputs `(("out" . "/bar"))))
(db-add-build (make-dummy-build "/baz.drv" 3
#:outputs `(("out" . "/baz"))))
- (db-add-evaluation (make-dummy-eval))
- (db-add-evaluation (make-dummy-eval))
- (db-add-evaluation (make-dummy-eval))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakesha1" "fakesha2"))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakesha1" "fakesha3"))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakssha2" "fakesha3"))
(db-add-specification example-spec)
(db-update-build-status! "/bar.drv" (build-status started)
@@ -188,9 +193,9 @@ INSERT INTO Evaluations (specification, commits) VALUES (3, 3);")
#:outputs `(("out" . "/bar"))))
(db-add-build (make-dummy-build "/foo.drv" 3
#:outputs `(("out" . "/foo"))))
- (db-add-evaluation (make-dummy-eval))
- (db-add-evaluation (make-dummy-eval))
- (db-add-evaluation (make-dummy-eval))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakesha1" "fakesha2"))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakesha1" "fakesha3"))
+ (db-add-evaluation "guix" (make-dummy-checkouts "fakssha2" "fakesha3"))
(db-add-specification example-spec)
(sort (db-get-pending-derivations) string<?)))
diff --git a/tests/http.scm b/tests/http.scm
index 38e4175..ae56356 100644
--- a/tests/http.scm
+++ b/tests/http.scm
@@ -44,9 +44,12 @@
(hash-table-keys t2))
(hash-fold (lambda (key value result)
(and result
- (let ((equal? (if (hash-table? value)
- hash-table=?
- equal?)))
+ (let ((equal?
+ (match value
+ ((? hash-table?) hash-table=?)
+ (((? hash-table?) ...)
+ (cut every hash-table=? <> <>))
+ (_ equal?))))
(equal? value
(hash-ref t2 key)))))
#t
@@ -95,9 +98,12 @@
(#:buildinputs_builds . #nil)))
(define evaluations-query-result
- '((#:id . 2)
- (#:specification . "guix")
- (#:commits . ("fakesha2" "fakesha3"))))
+ '(((#:id . 2)
+ (#:specification . "guix")
+ (#:in-progress . 1)
+ (#:checkouts . (((#:commit . "fakesha2")
+ (#:input . "savannah")
+ (#:directory . "dir3")))))))
(test-group-with-cleanup "http"
(test-assert "object->json-string"
@@ -180,18 +186,33 @@
(#:branch . "master")
(#:tag . #f)
(#:commit . #f)
+ (#:no-compile? . #f))
+ ((#:name . "packages")
+ (#:url . "git://git.savannah.gnu.org/guix.git")
+ (#:load-path . ".")
+ (#:branch . "master")
+ (#:tag . #f)
+ (#:commit . #f)
(#:no-compile? . #f))))))
- (evaluation1
- '((#:specification . "guix")
- (#:commits . ("fakesha1" "fakesha3"))))
- (evaluation2
- '((#:specification . "guix")
- (#:commits . ("fakesha2" "fakesha3")))))
+ (checkouts1
+ '(((#:commit . "fakesha1")
+ (#:input . "savannah")
+ (#:directory . "dir1"))
+ ((#:commit . "fakesha3")
+ (#:input . "packages")
+ (#:directory . "dir2"))))
+ (checkouts2
+ '(((#:commit . "fakesha2")
+ (#:input . "savannah")
+ (#:directory . "dir3"))
+ ((#:commit . "fakesha3")
+ (#:input . "packages")
+ (#:directory . "dir4")))))
(db-add-build build1)
(db-add-build build2)
(db-add-specification specification)
- (db-add-evaluation evaluation1)
- (db-add-evaluation evaluation2)))
+ (db-add-evaluation "guix" checkouts1)
+ (db-add-evaluation "guix" checkouts2)))
(test-assert "/build/1"
(hash-table=?
@@ -271,9 +292,9 @@
(and (= (length hash-list) 1)
(hash-table=?
(car hash-list)
- (call-with-input-string
- (object->json-string evaluations-query-result)
- json->scm)))))
+ (car (call-with-input-string
+ (object->json-string evaluations-query-result)
+ json->scm))))))
(test-assert "db-close"
(db-close (%db)))