Skip to content

Commit b96d55f

Browse files
committed
Add a test for out-of-order closes.
1 parent f439f12 commit b96d55f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

alloc_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package notmuch
2+
3+
// Copyright © 2015 The go.notmuch Authors. Authors can be found in the AUTHORS file.
4+
// Licensed under the GPLv3 or later.
5+
// See COPYING at the root of the repository for details.
6+
7+
// This file contains tests that exercise the resource creation/reclamation model.
8+
9+
import (
10+
"testing"
11+
)
12+
13+
// Basic test of the case where the user explicitly closes a parent object
14+
// before the child object. This is inevitable if Close is used at all; the
15+
// GC will close things child-first.
16+
func TestOutOfOrderClose(t *testing.T) {
17+
db, err := Open(dbPath, DBReadOnly)
18+
if err != nil {
19+
t.Fatalf("Open(%q): unexpected error: %s", dbPath, err)
20+
}
21+
22+
query := db.NewQuery("subject:\"Introducing myself\"")
23+
threads, err := query.Threads()
24+
if err != nil {
25+
t.Fatalf("error getting the threads: %s", err)
26+
}
27+
28+
db.Close()
29+
threads.Close()
30+
}

0 commit comments

Comments
 (0)