-
Notifications
You must be signed in to change notification settings - Fork 1
/
probes_test.go
53 lines (36 loc) · 985 Bytes
/
probes_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
package foundation
import (
"io/ioutil"
"net/http"
"testing"
"github.com/sethgrid/pester"
"github.com/stretchr/testify/assert"
)
func TestInitLivenessAndReadiness(t *testing.T) {
t.Run("Returns200OKForLiveness", func(t *testing.T) {
// act
InitLivenessAndReadinessWithPort(5002)
resp, err := pester.Get("http://localhost:5002/liveness")
if assert.Nil(t, err) {
assert.Equal(t, 200, resp.StatusCode)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if assert.Nil(t, err) {
assert.Equal(t, "I'm alive!\n", string(body))
}
}
})
t.Run("Returns200OKForReadiness", func(t *testing.T) {
// act
InitLivenessAndReadinessWithPort(5003)
resp, err := http.Get("http://localhost:5003/readiness")
if assert.Nil(t, err) {
assert.Equal(t, 200, resp.StatusCode)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if assert.Nil(t, err) {
assert.Equal(t, "I'm ready!\n", string(body))
}
}
})
}