cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.76.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

internal/config/options/selector_test.go

61lines · modecode

1package options_test
2
3import (
4 "errors"
5 "fmt"
6 "testing"
7
8 "github.com/stretchr/testify/require"
9
10 "github.com/cloudflare/pint/internal/config/options"
11)
12
13func TestSelectorSettings(t *testing.T) {
14 type testCaseT struct {
15 err error
16 conf options.SelectorSettings
17 }
18
19 testCases := []testCaseT{
20 {
21 conf: options.SelectorSettings{
22 Key: "summary",
23 RequiredLabels: []string{"foo"},
24 },
25 },
26 {
27 conf: options.SelectorSettings{},
28 err: errors.New("selector key cannot be empty"),
29 },
30 {
31 conf: options.SelectorSettings{
32 Key: ".++",
33 },
34 err: errors.New("error parsing regexp: invalid nested repetition operator: `++`"),
35 },
36 {
37 conf: options.SelectorSettings{
38 Key: ".+",
39 Severity: "foo",
40 },
41 err: errors.New("unknown severity: foo"),
42 },
43 {
44 conf: options.SelectorSettings{
45 Key: "summary",
46 },
47 err: errors.New("requiredLabels cannot be empty"),
48 },
49 }
50
51 for _, tc := range testCases {
52 t.Run(fmt.Sprintf("%v", tc.conf), func(t *testing.T) {
53 err := tc.conf.Validate()
54 if err == nil || tc.err == nil {
55 require.Equal(t, err, tc.err)
56 } else {
57 require.EqualError(t, err, tc.err.Error())
58 }
59 })
60 }
61}
62