-
Notifications
You must be signed in to change notification settings - Fork 11
/
config_test.go
65 lines (62 loc) · 1.55 KB
/
config_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
package patrol
import (
"os"
"testing"
)
const configStr = `
db: config-test.db
name: MyApp Status
port: 80
services:
API:
checks:
- name: API Status
interval: 60s
cmd: 'curl -fsSL https://app.myapp.com/api/v0/status'
on_failure:
- webhook:
method: delete
url: https://api.heroku.com/apps/MY_HEROKU_APP/dynos
headers:
Authorization: 'Bearer heroku-token'
Accept: 'application/vnd.heroku+json; version=3'
Web:
checks:
- name: Web delivers homepage
interval: 60s
cmd: 'curl -fsSL -o /dev/null https://app.myapp.ca/'
- name: Web delivers login
interval: 60s
cmd: 'curl -fsSL -o /dev/null https://app.myapp.ca/login'
- name: Homepage latency
type: metric
unit: ms
interval: 60s
cmd: 'curl -fsSL -w "%{time_total}" -o /dev/null https://google.ca'
Redis:
checks:
- name: Responds to pings
interval: 60s
cmd: '! redis-cli -h redis.ca -n 0 -a pass ping | grep ERR'
Mongo:
checks:
- name: Users exist
interval: 60s
cmd: 'echo doing stuff'
on_failure:
- command: echo hello world
on_success:
- webhook:
method: post
url: https://hooks.slack.com/services/MY_CUSTOM_WEBHOOK
headers:
'Content-Type': 'application/json'
body: '{"text":"Service \"{{service}}\" is up (check \"{{check.name}}\" completed)."}'
`
func TestConfigValidate(t *testing.T) {
os.Remove("config-test.db")
if _, _, err := FromConfig([]byte(configStr), nil); err != nil {
t.Error(err)
return
}
}