2020-09-08 17:49:02 -06:00
|
|
|
package transpile
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/afero"
|
|
|
|
)
|
|
|
|
|
|
|
|
var testMothYaml = []byte(`---
|
|
|
|
answers:
|
|
|
|
- YAML answer
|
2021-02-24 16:34:35 -07:00
|
|
|
authors:
|
|
|
|
- Arthur
|
|
|
|
- Buster
|
|
|
|
- DW
|
2021-02-25 13:07:44 -07:00
|
|
|
objective: moo like a cow
|
|
|
|
success:
|
|
|
|
acceptable: say moo
|
|
|
|
mastery: say mrr
|
2021-02-24 16:34:35 -07:00
|
|
|
attachments:
|
|
|
|
- moo.txt
|
2021-04-13 17:28:22 -06:00
|
|
|
ksas:
|
|
|
|
- a1
|
|
|
|
- b2
|
2020-09-08 17:49:02 -06:00
|
|
|
---
|
|
|
|
YAML body
|
|
|
|
`)
|
|
|
|
var testMothRfc822 = []byte(`author: test
|
|
|
|
Author: Arthur
|
|
|
|
author: Fred Flintstone
|
|
|
|
answer: RFC822 answer
|
|
|
|
|
|
|
|
RFC822 body
|
|
|
|
`)
|
2021-02-04 18:22:31 -07:00
|
|
|
var testMothMarkdown = []byte(`---
|
|
|
|
answers:
|
|
|
|
- answer
|
2021-02-24 16:34:35 -07:00
|
|
|
authors:
|
|
|
|
- Fred
|
2021-02-04 18:22:31 -07:00
|
|
|
---
|
|
|
|
|
|
|
|
one | two
|
|
|
|
--- | ---
|
|
|
|
1 | 2
|
|
|
|
|
|
|
|
Term
|
|
|
|
: definition of that term
|
|
|
|
`)
|
2020-09-08 17:49:02 -06:00
|
|
|
|
|
|
|
func newTestFs() afero.Fs {
|
|
|
|
fs := afero.NewMemMapFs()
|
|
|
|
afero.WriteFile(fs, "cat0/1/puzzle.md", testMothYaml, 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/1/moo.txt", []byte("Moo."), 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/2/puzzle.md", testMothRfc822, 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/3/puzzle.moth", testMothYaml, 0644)
|
2021-02-04 18:22:31 -07:00
|
|
|
afero.WriteFile(fs, "cat0/4/puzzle.md", testMothMarkdown, 0644)
|
2020-09-08 17:49:02 -06:00
|
|
|
afero.WriteFile(fs, "cat0/5/puzzle.md", testMothYaml, 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/10/puzzle.md", []byte(`---
|
|
|
|
Answers:
|
|
|
|
- moo
|
|
|
|
Authors:
|
|
|
|
- bad field
|
|
|
|
---
|
|
|
|
body
|
|
|
|
`), 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/20/puzzle.md", []byte("Answer: no\nBadField: yes\n\nbody\n"), 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/21/puzzle.md", []byte("Answer: broken\nSpooon\n"), 0644)
|
|
|
|
afero.WriteFile(fs, "cat0/22/puzzle.md", []byte("---\nanswers:\n - pencil\npre:\n unused-field: Spooon\n---\nSpoon?\n"), 0644)
|
|
|
|
afero.WriteFile(fs, "cat1/93/puzzle.md", []byte("Answer: no\n\nbody"), 0644)
|
|
|
|
afero.WriteFile(fs, "cat1/barney/puzzle.md", testMothYaml, 0644)
|
|
|
|
afero.WriteFile(fs, "unbroken/1/puzzle.md", testMothYaml, 0644)
|
|
|
|
afero.WriteFile(fs, "unbroken/1/moo.txt", []byte("Moo."), 0644)
|
|
|
|
afero.WriteFile(fs, "unbroken/2/puzzle.md", testMothRfc822, 0644)
|
|
|
|
return fs
|
|
|
|
}
|