mirror of https://github.com/perkeep/perkeep.git
search: add test for earlier fix in commit 1e1183a8bf
Change-Id: I95c0f885079de17cd1c52b9ad40861c96eb5308c
This commit is contained in:
parent
1e1183a8bf
commit
b020f60390
|
@ -22,6 +22,8 @@ func SetTestHookBug121(hook func()) {
|
|||
|
||||
func ExportCandSource() string { return candSource }
|
||||
|
||||
func ExportBufferedConst() int { return buffered }
|
||||
|
||||
func (s *SearchQuery) ExportPlannedQuery() *SearchQuery {
|
||||
return s.plannedQuery()
|
||||
}
|
||||
|
|
|
@ -566,6 +566,42 @@ func TestQueryRecentPermanodes(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestLimitDoesntDeadlock(t *testing.T) {
|
||||
// TODO: care about classic (allIndexTypes) too?
|
||||
testQueryTypes(t, memIndexTypes, func(qt *queryTest) {
|
||||
id := qt.id
|
||||
|
||||
const limit = 2
|
||||
for i := 0; i < ExportBufferedConst()+limit+1; i++ {
|
||||
pn := id.NewPlannedPermanode(fmt.Sprint(i))
|
||||
id.SetAttribute(pn, "foo", "bar")
|
||||
}
|
||||
|
||||
req := &SearchQuery{
|
||||
Constraint: &Constraint{
|
||||
Permanode: &PermanodeConstraint{},
|
||||
},
|
||||
Limit: limit,
|
||||
Sort: UnspecifiedSort,
|
||||
Describe: &DescribeRequest{},
|
||||
}
|
||||
h := qt.Handler()
|
||||
gotRes := make(chan bool, 1)
|
||||
go func() {
|
||||
_, err := h.Query(req)
|
||||
if err != nil {
|
||||
qt.t.Error(err)
|
||||
}
|
||||
gotRes <- true
|
||||
}()
|
||||
select {
|
||||
case <-gotRes:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Error("timeout; deadlock?")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func prettyJSON(v interface{}) string {
|
||||
b, err := json.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue