-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_test.go
57 lines (45 loc) · 1.19 KB
/
server_test.go
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
47
48
49
50
51
52
53
54
55
56
57
package main_test
import (
"os"
. "github.com/hyperboloide/qmail"
"github.com/hyperboloide/qmail/client"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Server", func() {
var cli *client.Mailer
It("should configure", func() {
Configure()
Ω(MainMailer).ToNot(BeNil())
})
It("should purge the queue", func() {
Ω(MainMailer.Queue.Purge()).To(BeNil())
})
It("should create a client", func() {
c, err := client.New(os.Getenv("QUEUE_NAME"), os.Getenv("QUEUE_HOST"))
Ω(err).To(BeNil())
cli = c
})
It("should send some mails and crash", func() {
errChan := make(chan error)
go func() {
errChan <- MainMailer.Queue.ListenBytes(MainMailer.Listenner)
}()
mOk := client.Mail{
Dests: []string{"[email protected]"},
Subject: "test",
Template: "example",
Data: map[string]string{"User": "test user"},
Files: []string{"./example.md"},
}
Ω(cli.Send(mOk)).To(BeNil())
mFail := client.Mail{
Dests: []string{"[email protected]"},
Subject: "test",
Template: "not_found",
Data: map[string]string{"User": "test user"},
}
Ω(cli.Send(mFail)).To(BeNil())
Ω(<-errChan).ToNot(BeNil())
})
})