Download this file
| 1 | package updatewords |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // TestDocsContainDrafts verifies that the CLI docs and README contain the |
| 10 | // drafts from words_surfaces.go byte for byte, so the docs and the drafts |
| 11 | // cannot drift before or after Paul's review. |
| 12 | func TestDocsContainDrafts(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | id string |
| 15 | path string |
| 16 | }{ |
| 17 | {"settings.cli.docs-instances-set", "../../docs/site/cli.md"}, |
| 18 | {"settings.cli.docs-instances-update", "../../docs/site/cli.md"}, |
| 19 | {"settings.cli.docs-apps-set-lead", "../../docs/site/cli.md"}, |
| 20 | {"settings.cli.docs-apps-set", "../../docs/site/cli.md"}, |
| 21 | {"settings.cli.roll-note", "../../README.md"}, |
| 22 | } |
| 23 | |
| 24 | for _, tt := range tests { |
| 25 | t.Run(tt.id, func(t *testing.T) { |
| 26 | txt := Text(tt.id) |
| 27 | if txt == "" { |
| 28 | t.Fatalf("no draft found for %s", tt.id) |
| 29 | } |
| 30 | |
| 31 | content, err := os.ReadFile(tt.path) |
| 32 | if err != nil { |
| 33 | t.Fatalf("reading %s: %v", tt.path, err) |
| 34 | } |
| 35 | |
| 36 | if !strings.Contains(string(content), txt) { |
| 37 | t.Errorf("%s does not contain the draft text for %s: %q", tt.path, tt.id, txt) |
| 38 | } |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | |