This repository has been archived by the owner on May 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
bootstrap_test.go
88 lines (63 loc) · 1.59 KB
/
bootstrap_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package dispatcher
import (
"errors"
"github.com/streadway/amqp"
"os"
"testing"
)
func Test_bootstrapExchanges1(t *testing.T) {
con, _ := amqp.Dial(os.Getenv("DISPATCHER_AMQP_CON"))
defer con.Close()
ch, _ := con.Channel()
defer ch.Close()
err := bootstrap(ch, "test_exchange_1", []Queue{
{"queue_1", []string{"key_1"}},
})
if err != nil {
t.Error(err)
return
}
ch.ExchangeDelete("test_exchange_1", false, false)
}
func Test_bootstrapExchanges2(t *testing.T) {
con, _ := amqp.Dial(os.Getenv("DISPATCHER_AMQP_CON"))
defer con.Close()
ch, _ := con.Channel()
defer ch.Close()
err := bootstrap(ch, "", []Queue{
{"queue_1", []string{"key_1"}},
})
if err == nil {
t.Error(errors.New("No error returned, but exchange was empty"))
return
}
ch.ExchangeDelete("test_exchange_1", false, false)
}
func Test_bootstrapExchanges3(t *testing.T) {
con, _ := amqp.Dial(os.Getenv("DISPATCHER_AMQP_CON"))
defer con.Close()
ch, _ := con.Channel()
defer ch.Close()
err := bootstrap(ch, "test_exchange_1", []Queue{
{"", []string{"key_1"}},
})
if err == nil {
t.Error(errors.New("No error returned, but queue was empty"))
return
}
ch.ExchangeDelete("test_exchange_1", false, false)
}
func Test_bootstrapExchanges4(t *testing.T) {
con, _ := amqp.Dial(os.Getenv("DISPATCHER_AMQP_CON"))
defer con.Close()
ch, _ := con.Channel()
defer ch.Close()
err := bootstrap(ch, "test_exchange_1", []Queue{
{"queue_1", []string{""}},
})
if err == nil {
t.Error(errors.New("No error returned, but binding key was empty"))
return
}
ch.ExchangeDelete("test_exchange_1", false, false)
}