mirror of https://github.com/zlatinb/muwire
fixes for not found scenarios
parent
e395c37c31
commit
01617f876d
|
@ -22,7 +22,7 @@ class SearchIndex {
|
|||
Set<String> rv = null;
|
||||
|
||||
terms.each {
|
||||
Set<String> forWord = keywords.get it
|
||||
Set<String> forWord = keywords.getOrDefault(it,[])
|
||||
if (rv == null) {
|
||||
rv = forWord
|
||||
} else {
|
||||
|
@ -31,6 +31,8 @@ class SearchIndex {
|
|||
|
||||
}
|
||||
|
||||
rv.asList()
|
||||
if (rv != null)
|
||||
return rv.asList()
|
||||
[]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,19 @@ class SearchIndexTest {
|
|||
assert found.size() == 1
|
||||
assert found.contains("c d.e")
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotFound() {
|
||||
initIndex(["a b.c"])
|
||||
def found = index.search(["d"])
|
||||
assert found.size() == 0
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSomeNotFound() {
|
||||
initIndex(["a b.c"])
|
||||
def found = index.search(["a","d"])
|
||||
assert found.size() == 0
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue