tests: Add search tests.
authorRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 14:51:28 +0000 (16:51 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 14:51:28 +0000 (16:51 +0200)
tests/data/spool/index.archive.realtime [new file with mode: 0644]
tests/data/spool/index.db.realtime [new file with mode: 0644]
tests/xapian.scm

diff --git a/tests/data/spool/index.archive.realtime b/tests/data/spool/index.archive.realtime
new file mode 100644 (file)
index 0000000..003ecb3
--- /dev/null
@@ -0,0 +1 @@
+guix-patches 26095 1489480202 done [Ricardo Wurmus <rekado@example.com>] normal 
diff --git a/tests/data/spool/index.db.realtime b/tests/data/spool/index.db.realtime
new file mode 100644 (file)
index 0000000..5e514fb
--- /dev/null
@@ -0,0 +1 @@
+guix 33299 1541585102 open [user <user@example.com>] important unreproducible
index a609210a2d945d94feec270daeeb66b6d1c1f151..20ded376be06c033fe1de2fafb99a2b8393a7d45 100644 (file)
@@ -19,7 +19,8 @@
   #:use-module (mumi xapian)
   #:use-module (mumi test-utils)
   #:use-module (srfi srfi-19)
-  #:use-module (srfi srfi-64))
+  #:use-module (srfi srfi-64)
+  #:use-module (ice-9 match))
 
 (test-begin "xapian")
 
   (tokenize "subject:\"hello world\" how \"are\" you")
   '("subject:\"hello world\"" "how" "\"are\"" "you"))
 
+(define data-dir
+  (string-append (getenv "abs_top_srcdir") "/tests/data"))
+(define db-dir (tmpnam))
+(mkdir db-dir)
+
+(mock ((mumi config) %config
+       (match-lambda
+         ('cache-ttl 10)
+         ('db-dir db-dir)
+         ('data-dir data-dir)
+         ('packages '("guix"))))
+      (index! #:full? #t)
+      (dynamic-wind
+        (lambda () #t)
+        (lambda ()
+          (test-equal "search: finds simple strings"
+            '("33299")
+            (search "hello" #:pagesize 2))
+          (test-equal "search: supports submitter prefix with name"
+            '("26095")
+            (search "submitter:Ricardo" #:pagesize 2))
+          (test-equal "search: supports submitter prefix with partial email address"
+            '("26095")
+            (search "submitter:rekado" #:pagesize 2))
+          (test-equal "search: supports author prefix with email address"
+            '("26095" "33299")
+            (search "author:ludo" #:pagesize 2)))
+        (lambda ()
+          (delete-file-recursively db-dir))))
+
 (test-end "xapian")