26 #include <wibble/sys/fs.h>
30 namespace textsearch {
37 using namespace ept::textsearch;
38 using namespace ept::apt;
44 wibble::sys::fs::mkdirIfMissing(name, 0755);
56 : md( TEST_ENV_DIR
"xapian"), oid( TEST_ENV_DIR
"xapian")
60 textsearch.rebuildIfNeeded(apt);
61 }
catch (Xapian::Error& e) {
62 cerr << e.get_type() <<
" " << e.get_msg() <<
" " << e.get_context() << endl;
86 assert(textsearch.hasData());
87 assert(textsearch.timestamp() > 0);
88 assert(!textsearch.needsRebuild(apt));
90 Xapian::Enquire enq(textsearch.db());
91 enq.set_query(textsearch.makeORQuery(
"sgml"));
92 Xapian::MSet matches = enq.get_mset(0, 100);
93 assert(matches.size() > 0);
97 for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
98 results.insert(i.get_document().get_data());
99 assert(results.find(
"sp") != results.end());
105 Xapian::Enquire enq(textsearch.db());
106 enq.set_query(textsearch.makeORQuery(
"sgml"));
107 Xapian::MSet matches = enq.get_mset(0, 100);
108 assert(matches.size() > 0);
112 for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
113 results.insert(i.get_document().get_data());
114 assert(results.find(
"sp") != results.end());
120 Xapian::Enquire enq(textsearch.db());
121 enq.set_query(textsearch.makePartialORQuery(
"sgml"));
122 Xapian::MSet matches = enq.get_mset(0, 100);
123 assert(matches.size() > 0);
127 for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i)
128 results.insert(i.get_document().get_data());
129 assert(results.find(
"sp") != results.end());
135 assert(textsearch.docidByName(
"sp") != 0);
136 assert_eq(textsearch.docidByName(
"thereisnopackagewiththisname"), 0u);
142 assert(textsearch.hasData());
143 assert(textsearch.timestamp() > 0);
144 assert(!textsearch.needsRebuild(apt));
148 assert(dval == 2408);
150 assert(dval == 741486);
152 assert_eq(textsearch.getDoubleValue(
"thereisnopackagewiththisname",
VAL_APT_PACKAGE_SIZE), 0.0);
158 assert(val == 741486);
DirMaker md
Definition: textsearch.test.h:50
time_t timestamp() const
Timestamp of when the Xapian database was last updated.
Definition: textsearch.h:136
Test values()
Definition: textsearch.test.h:140
Apt apt
Definition: textsearch.test.h:52
Definition: textsearch/maint/path.h:51
Definition: textsearch.test.h:40
DirMaker(const std::string &name)
Definition: textsearch.test.h:42
Test docidByName()
Definition: textsearch.test.h:133
High-level access to the Apt cache, as a data provider for the ept framework.
Definition: apt/apt.h:60
Test queryAccess()
Definition: textsearch.test.h:103
High-level front-end to libapt-pkg, as a data provider for the ept framework.
bool hasData() const
Returns true if the index has data.
Definition: textsearch.h:139
Maintains and accesses a Xapian index of package descriptions.
Definition: textsearch.h:102
const Xapian::valueno VAL_APT_INSTALLED_SIZE
Definition: xapian.h:16
Test basicAccess()
Definition: textsearch.test.h:84
TextSearch textsearch
Definition: textsearch.test.h:53
Definition: textsearch.test.h:48
Test partialOrQuery()
Definition: textsearch.test.h:118
TestTextsearch()
Definition: textsearch.test.h:55
Test empty()
Definition: textsearch.test.h:68
size_t max_index
Definition: textsearch.cc:48
const Xapian::valueno VAL_APT_PACKAGE_SIZE
Definition: xapian.h:17
Path::OverrideIndexDir oid
Definition: textsearch.test.h:51
bool needsRebuild(apt::Apt &apt)
Returns true if the index is older than the Apt database information.
Definition: textsearch.cc:67