diff --git a/items/.empty b/items/.empty new file mode 100644 index 0000000..e69de29 diff --git a/test/common b/test/common new file mode 100644 index 0000000..0d61ec2 --- /dev/null +++ b/test/common @@ -0,0 +1,33 @@ +#!/bin/bash + +lastgiven='' +lastexpected='' + +last() +{ + lastgiven="$1" + lastexpected="$2" +} + + +assert-equal() +{ + last "$1" "$2" + [ "$1" == "$2" ] +} + + +assert-eq() +{ + last "$1" "$2" + [ $1 -eq $2 ] +} + + +fail() +{ + echo "FAILURE: $1" >&2 + echo "Expected '$lastexpected', but received '$lastgiven'" >&2 + echo >&2 +} + diff --git a/test/test-common-inv b/test/test-common-inv new file mode 100755 index 0000000..0c1e4ad --- /dev/null +++ b/test/test-common-inv @@ -0,0 +1,37 @@ +#!/bin/bash + +mypath=$( dirname $0 ) +. "$mypath/common" +. "$mypath/../util/common-inv" + +#expected values +eid=_foo +ename="Large Ugly Foobar" +ecount=5 + +# test item tag +item="$ecount:$eid" + + +# let's write a temporary item for testing +itemfile="$mypath/../items/_foo" +cat > $itemfile <" + cat "$itemdir/$id" <<< "$1" \ + | grep '^NAME ' \ + | cut -d' ' -f2- +} + + +inv-item-id() +{ + cut -d':' -f2 <<< "$1" +} + + +inv-item-count() +{ + cut -d':' -f1 <<< "$1" +} +