diff options
Diffstat (limited to 'tests/xapian.scm')
-rw-r--r-- | tests/xapian.scm | 33 |
1 files changed, 32 insertions, 1 deletions
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") |