File: snippet_test.go

package info (click to toggle)
golang-github-juju-names 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 340 kB
  • sloc: makefile: 14
file content (33 lines) | stat: -rw-r--r-- 730 bytes parent folder | download
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
package names

import (
	"strings"

	gc "gopkg.in/check.v1"
)

var snippets = []struct {
	name    string
	snippet string
}{
	{"ContainerTypeSnippet", ContainerTypeSnippet},
	{"ContainerSnippet", ContainerSnippet},
	{"MachineSnippet", MachineSnippet},
	{"NumberSnippet", NumberSnippet},
	{"ApplicationSnippet", ApplicationSnippet},
	{"RelationSnippet", RelationSnippet},
}

type snippetSuite struct{}

var _ = gc.Suite(&snippetSuite{})

func (s *equalitySuite) TestSnippetsContainNoCapturingGroups(c *gc.C) {
	for _, test := range snippets {
		for i, ch := range test.snippet {
			if ch == '(' && !strings.HasPrefix(test.snippet[i:], "(?:") {
				c.Errorf("%s (%q) contains capturing group", test.name, test.snippet)
			}
		}
	}
}