File: alloc_test.go

package info (click to toggle)
golang-github-zenhack-go.notmuch 0.0~git20190821.5a19619-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 240 kB
  • sloc: makefile: 22
file content (30 lines) | stat: -rw-r--r-- 843 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package notmuch

// Copyright © 2015 The go.notmuch Authors. Authors can be found in the AUTHORS file.
// Licensed under the GPLv3 or later.
// See COPYING at the root of the repository for details.

// This file contains tests that exercise the resource creation/reclamation model.

import (
	"testing"
)

// Basic test of the case where the user explicitly closes a parent object
// before the child object. This is inevitable if Close is used at all; the
// GC will close things child-first.
func TestOutOfOrderClose(t *testing.T) {
	db, err := Open(dbPath, DBReadOnly)
	if err != nil {
		t.Fatalf("Open(%q): unexpected error: %s", dbPath, err)
	}

	query := db.NewQuery("subject:\"Introducing myself\"")
	threads, err := query.Threads()
	if err != nil {
		t.Fatalf("error getting the threads: %s", err)
	}

	db.Close()
	threads.Close()
}