summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/data/spool/index.archive.realtime1
-rw-r--r--tests/data/spool/index.db.realtime1
-rw-r--r--tests/xapian.scm33
3 files changed, 34 insertions, 1 deletions
diff --git a/tests/data/spool/index.archive.realtime b/tests/data/spool/index.archive.realtime
new file mode 100644
index 0000000..003ecb3
--- /dev/null
+++ b/tests/data/spool/index.archive.realtime
@@ -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
index 0000000..5e514fb
--- /dev/null
+++ b/tests/data/spool/index.db.realtime
@@ -0,0 +1 @@
+guix 33299 1541585102 open [user <user@example.com>] important unreproducible
diff --git a/tests/xapian.scm b/tests/xapian.scm
index a609210..20ded37 100644
--- a/tests/xapian.scm
+++ b/tests/xapian.scm
@@ -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")
@@ -70,4 +71,34 @@
(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")