-
Notifications
You must be signed in to change notification settings - Fork 0
/
backends_test.go
52 lines (44 loc) · 1.04 KB
/
backends_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
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func setUpBackend() *BaseBackend {
bb, _ := NewBaseBackend("127.0.0.1", 8000)
return bb
}
func TestCreateBaseBackend(t *testing.T) {
bb, err := NewBaseBackend("127.0.0.1", 8000)
assert.NoError(t, err)
assert.Equal(t, bb, setUpBackend())
}
func TestCreateBaseBackendWrongValues(t *testing.T) {
bb, err := NewBaseBackend("555.555.332.221", -8000)
assert.EqualError(t, err, "IP and Port can't have negative values!")
assert.Nil(t, bb)
}
func TestIsBackendDown(t *testing.T) {
bb := setUpBackend()
bb.Down = true
down := bb.IsDown()
assert.Equal(t, down, true)
}
func TestIsBackendUp(t *testing.T) {
bb := setUpBackend()
down := bb.IsDown()
assert.Equal(t, down, false)
}
func TestVerifyBackendifDown(t *testing.T) {
bb := setUpBackend()
bb.Verify()
bb.Down = true
down := bb.IsDown()
assert.Equal(t, down, true)
}
func TestVerifyBackendifUp(t *testing.T) {
bb := setUpBackend()
bb.Verify()
bb.Down = false
down := bb.IsDown()
assert.Equal(t, down, false)
}