File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55
66package provider_test
7+
8+ import (
9+ "bufio"
10+ "os"
11+ "regexp"
12+ "strings"
13+ "testing"
14+ )
15+
16+ func TestProviderDocumentation (t * testing.T ) {
17+ file , err := os .Open ("../../docs/data-sources/external_secrets_io_cluster_secret_store_v1alpha1_manifest.md" )
18+ if err != nil {
19+ t .Fatal (err )
20+ }
21+ defer file .Close ()
22+
23+ linkPattern := regexp .MustCompile (`<a id="nestedatt--(?P<DashedPath>.*)"></a>` )
24+ titlePattern := regexp .MustCompile ("### Nested Schema for `(?P<DottedPath>.*)`" )
25+ expectedTitle := ""
26+
27+ scanner := bufio .NewScanner (file )
28+ for scanner .Scan () {
29+ line := scanner .Text ()
30+
31+ link := linkPattern .FindStringSubmatch (line )
32+ title := titlePattern .FindStringSubmatch (line )
33+
34+ if len (link ) > 0 {
35+ attributeIndex := linkPattern .SubexpIndex ("DashedPath" )
36+ attributeValue := link [attributeIndex ]
37+ expectedTitle = strings .ReplaceAll (attributeValue , "--" , "." )
38+ }
39+ if len (title ) > 0 {
40+ pathIndex := titlePattern .SubexpIndex ("DottedPath" )
41+ pathValue := title [pathIndex ]
42+ if expectedTitle != pathValue {
43+ t .Errorf ("Wanted [%s] but got [%s]" , expectedTitle , pathValue )
44+ }
45+ }
46+ }
47+
48+ if err := scanner .Err (); err != nil {
49+ t .Fatal (err )
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments