cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.55.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

internal/config/checks_test.go

51lines · modecode

1package config
2
3import (
4 "errors"
5 "fmt"
6 "testing"
7
8 "github.com/stretchr/testify/require"
9)
10
11func TestChecksSettings(t *testing.T) {
12 type testCaseT struct {
13 conf Checks
14 err error
15 }
16
17 testCases := []testCaseT{
18 {
19 conf: Checks{},
20 },
21 {
22 conf: Checks{
23 Enabled: []string{"foo"},
24 },
25 err: errors.New("unknown check name foo"),
26 },
27 {
28 conf: Checks{
29 Disabled: []string{"foo"},
30 },
31 err: errors.New("unknown check name foo"),
32 },
33 {
34 conf: Checks{
35 Enabled: []string{"promql/syntax"},
36 Disabled: []string{"promql/syntax"},
37 },
38 },
39 }
40
41 for _, tc := range testCases {
42 t.Run(fmt.Sprintf("%v", tc.conf), func(t *testing.T) {
43 err := tc.conf.validate()
44 if err == nil || tc.err == nil {
45 require.Equal(t, err, tc.err)
46 } else {
47 require.EqualError(t, err, tc.err.Error())
48 }
49 })
50 }
51}
52