Neale Pickett
·
2021-04-13
common_test.go
1package transpile
2
3import (
4 "github.com/spf13/afero"
5)
6
7var testMothYaml = []byte(`---
8answers:
9 - YAML answer
10authors:
11 - Arthur
12 - Buster
13 - DW
14objective: moo like a cow
15success:
16 acceptable: say moo
17 mastery: say mrr
18attachments:
19 - moo.txt
20ksas:
21 - a1
22 - b2
23---
24YAML body
25`)
26var testMothRfc822 = []byte(`author: test
27Author: Arthur
28author: Fred Flintstone
29answer: RFC822 answer
30
31RFC822 body
32`)
33var testMothMarkdown = []byte(`---
34answers:
35 - answer
36authors:
37 - Fred
38---
39
40one | two
41--- | ---
421 | 2
43
44Term
45: definition of that term
46`)
47
48func newTestFs() afero.Fs {
49 fs := afero.NewMemMapFs()
50 afero.WriteFile(fs, "cat0/1/puzzle.md", testMothYaml, 0644)
51 afero.WriteFile(fs, "cat0/1/moo.txt", []byte("Moo."), 0644)
52 afero.WriteFile(fs, "cat0/2/puzzle.md", testMothRfc822, 0644)
53 afero.WriteFile(fs, "cat0/3/puzzle.moth", testMothYaml, 0644)
54 afero.WriteFile(fs, "cat0/4/puzzle.md", testMothMarkdown, 0644)
55 afero.WriteFile(fs, "cat0/5/puzzle.md", testMothYaml, 0644)
56 afero.WriteFile(fs, "cat0/10/puzzle.md", []byte(`---
57Answers:
58 - moo
59Authors:
60 - bad field
61---
62body
63`), 0644)
64 afero.WriteFile(fs, "cat0/20/puzzle.md", []byte("Answer: no\nBadField: yes\n\nbody\n"), 0644)
65 afero.WriteFile(fs, "cat0/21/puzzle.md", []byte("Answer: broken\nSpooon\n"), 0644)
66 afero.WriteFile(fs, "cat0/22/puzzle.md", []byte("---\nanswers:\n - pencil\npre:\n unused-field: Spooon\n---\nSpoon?\n"), 0644)
67 afero.WriteFile(fs, "cat1/93/puzzle.md", []byte("Answer: no\n\nbody"), 0644)
68 afero.WriteFile(fs, "cat1/barney/puzzle.md", testMothYaml, 0644)
69 afero.WriteFile(fs, "unbroken/1/puzzle.md", testMothYaml, 0644)
70 afero.WriteFile(fs, "unbroken/1/moo.txt", []byte("Moo."), 0644)
71 afero.WriteFile(fs, "unbroken/2/puzzle.md", testMothRfc822, 0644)
72 return fs
73}