-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
63 lines (52 loc) · 1.39 KB
/
main_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
// +build unit
package main
import (
"context"
"testing"
"time"
"github.com/krzysztof-gzocha/pingor/pkg/config"
"github.com/krzysztof-gzocha/pingor/pkg/log"
"github.com/stretchr/testify/assert"
)
func TestRun_NotPanics_WithDynamoDB(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), time.Millisecond*100)
defer cancel()
cfg := config.Config{
RawConfig: config.RawConfig{
Dns: config.DnsConfig{Hosts: []string{"wp.pl"}},
Http: config.HttpConfig{Urls: []string{"wp.pl"}},
Persister: config.Persister{DynamoDB: config.DynamoDbPersister{
Enabled: true,
Region: "test",
}},
},
}
assert.NotPanics(t, func() {
run(ctx, cfg, &log.Nil{})
})
}
func TestRun_NotPanics_WithoutDynamoDB(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), time.Millisecond*100)
defer cancel()
cfg := config.Config{
RawConfig: config.RawConfig{
Dns: config.DnsConfig{Hosts: []string{"wp.pl"}},
Http: config.HttpConfig{Urls: []string{"wp.pl"}},
},
}
assert.NotPanics(t, func() {
run(ctx, cfg, &log.Nil{})
})
}
func TestGetCheckers(t *testing.T) {
logger := &log.Nil{}
cfg := config.Config{
RawConfig: config.RawConfig{
Metrics: config.Metrics{Enabled: true},
Dns: config.DnsConfig{Hosts: []string{"wp.pl"}},
Http: config.HttpConfig{Urls: []string{"wp.pl"}},
},
}
checkers := getCheckers(logger, cfg)
assert.Len(t, checkers, 2)
}