MCPcopy
hub / github.com/perkeep/perkeep / testLimitDoesntDeadlock

Function testLimitDoesntDeadlock

pkg/search/query_test.go:1779–1812  ·  view source on GitHub ↗
(t *testing.T, sortType SortType)

Source from the content-addressed store, hash-verified

1777}
1778
1779func testLimitDoesntDeadlock(t *testing.T, sortType SortType) {
1780 testQueryTypes(t, memIndexTypes, func(qt *queryTest) {
1781 id := qt.id
1782
1783 const limit = 2
1784 for i := 0; i < ExportBufferedConst()+limit+1; i++ {
1785 pn := id.NewPlannedPermanode(fmt.Sprint(i))
1786 id.SetAttribute(pn, "foo", "bar")
1787 }
1788
1789 req := &SearchQuery{
1790 Constraint: &Constraint{
1791 Permanode: &PermanodeConstraint{},
1792 },
1793 Limit: limit,
1794 Sort: sortType,
1795 Describe: &DescribeRequest{},
1796 }
1797 h := qt.Handler()
1798 gotRes := make(chan bool, 1)
1799 go func() {
1800 _, err := h.Query(ctxbg, req)
1801 if err != nil {
1802 qt.t.Error(err)
1803 }
1804 gotRes <- true
1805 }()
1806 select {
1807 case <-gotRes:
1808 case <-time.After(5 * time.Second):
1809 t.Error("timeout; deadlock?")
1810 }
1811 })
1812}
1813
1814func prettyJSON(v interface{}) string {
1815 b, err := json.MarshalIndent(v, "", " ")

Calls 7

testQueryTypesFunction · 0.85
ExportBufferedConstFunction · 0.85
NewPlannedPermanodeMethod · 0.80
SetAttributeMethod · 0.80
HandlerMethod · 0.80
QueryMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected