-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs_test.go
More file actions
68 lines (59 loc) · 2.95 KB
/
docs_test.go
File metadata and controls
68 lines (59 loc) · 2.95 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package prmaven_test
import (
"os"
"strings"
"testing"
)
func TestDocumentationCoversInstallationUsageAndExamples(t *testing.T) {
files := map[string]string{
"README.md": mustReadFile(t, "README.md"),
"docs/installation.md": mustReadFile(t, "docs/installation.md"),
"docs/integrations.md": mustReadFile(t, "docs/integrations.md"),
"docs/permissions.md": mustReadFile(t, "docs/permissions.md"),
"docs/usage.md": mustReadFile(t, "docs/usage.md"),
"examples/README.md": mustReadFile(t, "examples/README.md"),
"examples/library/main.go": mustReadFile(t, "examples/library/main.go"),
}
assertContains(t, files["README.md"], "[Installation](docs/installation.md)")
assertContains(t, files["README.md"], "[Usage guide](docs/usage.md)")
assertContains(t, files["README.md"], "[Examples](examples/README.md)")
assertContains(t, files["README.md"], "[Integrations](docs/integrations.md)")
assertContains(t, files["README.md"], "[Permission posture](docs/permissions.md)")
assertContains(t, files["docs/installation.md"], "go install ./cmd/prmaven")
assertContains(t, files["docs/integrations.md"], "No native GitHub API adapter yet.")
assertContains(t, files["docs/integrations.md"], "GitHub is the only platform with official project automation and example coverage today")
assertContains(t, files["docs/permissions.md"], "Do not switch it to private if that would disable branch protection or repository rules.")
assertContains(t, files["docs/permissions.md"], "All CI checks")
assertContains(t, files["docs/installation.md"], "prmaven version")
assertContains(t, files["docs/usage.md"], "prmaven fails -project .")
assertContains(t, files["docs/usage.md"], "demo/multi-module-failure")
assertContains(t, files["docs/usage.md"], "demo/no-failure")
assertContains(t, files["examples/README.md"], "go run ./examples/library demo/multi-module-failure")
assertContains(t, files["examples/library/main.go"], "prmaven.Analyze")
}
func TestDocumentationUsesPublicFounderIdentity(t *testing.T) {
files := map[string]string{
"README.md": mustReadFile(t, "README.md"),
"MANIFESTO.md": mustReadFile(t, "MANIFESTO.md"),
"GOVERNANCE.md": mustReadFile(t, "GOVERNANCE.md"),
"MAINTAINERS.md": mustReadFile(t, "MAINTAINERS.md"),
"docs/permissions.md": mustReadFile(t, "docs/permissions.md"),
}
assertContains(t, files["README.md"], "PR Maven CLI was founded by Will-thom.")
assertContains(t, files["MANIFESTO.md"], "Will-thom is the public founder identity for this project.")
assertContains(t, files["GOVERNANCE.md"], "PR Maven CLI is founded by Will-thom.")
}
func mustReadFile(t *testing.T, path string) string {
t.Helper()
contents, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
return string(contents)
}
func assertContains(t *testing.T, text, expected string) {
t.Helper()
if !strings.Contains(text, expected) {
t.Fatalf("documentation missing %q", expected)
}
}