-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackendtests_test.go
More file actions
46 lines (37 loc) · 910 Bytes
/
backendtests_test.go
File metadata and controls
46 lines (37 loc) · 910 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package imapmaildir
import (
"io/ioutil"
"log"
"os"
"strings"
"testing"
backendtests "github.com/foxcpp/go-imap-backend-tests"
)
func initTestBackend() backendtests.Backend {
tempDir, err := ioutil.TempDir("", "go-imap-maildir-")
if err != nil {
panic(err)
}
be, err := New(tempDir + "/{username}")
if err != nil {
panic(err)
}
if testing.Verbose() {
be.Log = log.New(os.Stderr, "imapmaildir: ", log.LstdFlags)
be.Debug = log.New(os.Stderr, "imapmaildir[debug]: ", log.LstdFlags)
}
return be
}
func cleanBackend(b backendtests.Backend) {
be := b.(*Backend)
if os.Getenv("KEEP_IMAPMAILDIR") == "1" {
log.Println("Maildirs in", be.PathTemplate, "are not deleted")
return
}
if err := os.RemoveAll(strings.TrimSuffix(be.PathTemplate, "/{username}")); err != nil {
panic(err)
}
}
func TestBackend(t *testing.T) {
backendtests.RunTests(t, initTestBackend, cleanBackend)
}