forked from cep21/circuit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager_test.go
51 lines (46 loc) · 1.1 KB
/
manager_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
package circuit
import (
"strings"
"testing"
)
func TestManager_Empty(t *testing.T) {
h := Manager{}
if h.GetCircuit("does_not_exist") != nil {
t.Error("found a circuit that does not exist")
}
}
func TestManager_Var(t *testing.T) {
h := Manager{}
c := h.MustCreateCircuit("hello-world", Config{})
if !strings.Contains(h.Var().String(), "hello-world") {
t.Error("Var() does not seem to work for hystrix", h.Var())
}
if !strings.Contains(c.Var().String(), "hello-world") {
t.Error("Var() does not seem to work for circuits")
}
}
func TestSimpleCreate(t *testing.T) {
h := Manager{}
c := h.MustCreateCircuit("hello-world", Config{})
if c.Name() != "hello-world" {
t.Error("unexpeted name")
}
c = h.GetCircuit("hello-world")
if c.Name() != "hello-world" {
t.Error("unexpeted name")
}
}
func TestDoubleCreate(t *testing.T) {
h := Manager{}
h.MustCreateCircuit("hello-world", Config{})
var foundErr interface{}
func() {
defer func() {
foundErr = recover()
}()
h.MustCreateCircuit("hello-world", Config{})
}()
if foundErr == nil {
t.Error("Expect panic when must creating twice")
}
}