cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.29.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

internal/config/alerts_test.go

69lines · modecode

1package config
2
3import (
4 "errors"
5 "fmt"
6 "testing"
7
8 "github.com/stretchr/testify/require"
9)
10
11func TestAlertsSettings(t *testing.T) {
12 type testCaseT struct {
13 conf AlertsSettings
14 err error
15 }
16
17 testCases := []testCaseT{
18 {
19 conf: AlertsSettings{
20 Range: "7d",
21 },
22 },
23 {
24 conf: AlertsSettings{
25 Step: "7d",
26 },
27 },
28 {
29 conf: AlertsSettings{
30 Resolve: "7d",
31 },
32 },
33 {
34 conf: AlertsSettings{
35 Range: "foo",
36 Step: "1m",
37 Resolve: "5m",
38 },
39 err: errors.New(`not a valid duration string: "foo"`),
40 },
41 {
42 conf: AlertsSettings{
43 Range: "7d",
44 Step: "foo",
45 Resolve: "5m",
46 },
47 err: errors.New(`not a valid duration string: "foo"`),
48 },
49 {
50 conf: AlertsSettings{
51 Range: "7d",
52 Step: "1m",
53 Resolve: "foo",
54 },
55 err: errors.New(`not a valid duration string: "foo"`),
56 },
57 }
58
59 for _, tc := range testCases {
60 t.Run(fmt.Sprintf("%v", tc.conf), func(t *testing.T) {
61 err := tc.conf.validate()
62 if err == nil || tc.err == nil {
63 require.Equal(t, err, tc.err)
64 } else {
65 require.EqualError(t, err, tc.err.Error())
66 }
67 })
68 }
69}
70