From ff99f131ea4a6eb4a96418c27860d5ce416b8ddd Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 5 Mar 2021 14:42:57 -0700 Subject: [PATCH] fix test --- cmd/mothd/testdata/cat0/2/mkpuzzle | 36 ++++++++++++++++++++++++++++++ cmd/mothd/transpiler_test.go | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 cmd/mothd/testdata/cat0/2/mkpuzzle diff --git a/cmd/mothd/testdata/cat0/2/mkpuzzle b/cmd/mothd/testdata/cat0/2/mkpuzzle new file mode 100755 index 0000000..cb0c887 --- /dev/null +++ b/cmd/mothd/testdata/cat0/2/mkpuzzle @@ -0,0 +1,36 @@ +#! /bin/sh + +fail () { + echo "ERROR: $*" 1>&2 + exit 1 +} + +case $1:$2 in + puzzle:) + cat <<'EOT' +{ + "Answers": ["answer"], + "Authors": ["neale"], + "Body": "I am a generated puzzle." +} +EOT + ;; + file:moo.txt) + echo "Moo." + ;; + file:*) + fail "no such file: $1" + ;; + answer:moo) + echo '{"Correct":true}' + ;; + answer:error) + fail "you requested an error" + ;; + answer:*) + echo '{"Correct":false}' + ;; + *) + fail "What is $1" + ;; +esac diff --git a/cmd/mothd/transpiler_test.go b/cmd/mothd/transpiler_test.go index 20dfd92..8cd562e 100644 --- a/cmd/mothd/transpiler_test.go +++ b/cmd/mothd/transpiler_test.go @@ -13,7 +13,7 @@ func TestTranspiler(t *testing.T) { inv := p.Inventory() if len(inv) != 1 { t.Error("Wrong inventory:", inv) - } else if len(inv[0].Puzzles) != 1 { - t.Error("Wrong inventory:", inv) + } else if len(inv[0].Puzzles) != 2 { + t.Error("Wrong puzzles:", inv) } }