mirror of https://github.com/dirtbags/moth.git
Attempt to reproduce #154
This commit is contained in:
parent
e771ae88c1
commit
8bc5dfd784
|
@ -5,6 +5,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dirtbags/moth/pkg/transpile"
|
||||
|
@ -163,3 +164,22 @@ func TestMothballs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilesystem(t *testing.T) {
|
||||
stdout := new(bytes.Buffer)
|
||||
stderr := new(bytes.Buffer)
|
||||
tp := T{
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
BaseFs: afero.NewOsFs(),
|
||||
}
|
||||
|
||||
stdout.Reset()
|
||||
if err := tp.Run("file", "-dir=testdata/cat1/1", "-file=moo.txt"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !strings.Contains(stdout.String(), "Moo.") {
|
||||
t.Error("Wrong file pulled", stdout.String())
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#! /bin/sh
|
||||
|
||||
fail () {
|
||||
echo "ERROR: $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
case $1:$2 in
|
||||
puzzle:)
|
||||
cat <<'EOT'
|
||||
{
|
||||
"Answers": ["answer"],
|
||||
"Pre": {
|
||||
"Authors": ["neale"],
|
||||
"Body": "I am a generated puzzle."
|
||||
}
|
||||
}
|
||||
EOT
|
||||
;;
|
||||
file:moo.txt)
|
||||
echo "Moo."
|
||||
;;
|
||||
file:*)
|
||||
cat "$2" || exit 1
|
||||
;;
|
||||
answer:moo)
|
||||
echo '{"Correct":true}'
|
||||
;;
|
||||
answer:error)
|
||||
fail "you requested an error"
|
||||
;;
|
||||
answer:*)
|
||||
echo '{"Correct":false}'
|
||||
;;
|
||||
*)
|
||||
fail "What is $1"
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,8 @@
|
|||
______
|
||||
< moo. >
|
||||
------
|
||||
\ ^__^
|
||||
\ (oo)\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
Loading…
Reference in New Issue