forked from statping/emails
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompiled_test.go
50 lines (44 loc) · 1.2 KB
/
compiled_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
package emails
import (
"fmt"
"github.com/statping/statping-ng/types/core"
"github.com/statping/statping-ng/types/failures"
"github.com/statping/statping-ng/types/services"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
type replacer struct {
Core core.Core
Service services.Service
Failure failures.Failure
Custom map[string]string
Email string
}
func TestServiceOnline(t *testing.T) {
example := services.Example(true)
replaced := replacer{
Core: *core.Example(),
Service: example,
Failure: failures.Example(),
Email: "[email protected]",
}
tmpl, err := Parse(Success, replaced)
require.Nil(t, err)
assert.Contains(t, tmpl, example.Name)
assert.Contains(t, tmpl, fmt.Sprintf("%0.0f seconds", example.Downtime().Seconds()))
}
func TestServiceOffline(t *testing.T) {
example := services.Example(false)
failure := failures.Example()
replaced := &replacer{
Core: *core.Example(),
Service: example,
Failure: failure,
Email: "[email protected]",
}
tmpl, err := Parse(Failure, replaced)
require.Nil(t, err)
assert.Contains(t, tmpl, example.Name)
assert.Contains(t, tmpl, fmt.Sprintf("%0.0f seconds", example.Downtime().Seconds()))
}