From 4811afc03e8c35ab20a47aefbf1bab839e5cd092 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 10 May 2020 16:51:28 +0200 Subject: tests: Add search tests. --- tests/data/spool/index.archive.realtime | 1 + tests/data/spool/index.db.realtime | 1 + tests/xapian.scm | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/data/spool/index.archive.realtime create mode 100644 tests/data/spool/index.db.realtime (limited to 'tests') 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 ] 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 ] 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") -- cgit v1.2.3