Cover some additional error cases.
Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
test/ext/test-misc | 13 -------------
test/ext/test-tag | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 13 deletions(-)
create mode 100755 test/ext/test-tag
diff --git a/test/ext/test-misc b/test/ext/test-misc
index bd60431a..1f70eb57 100755
--- a/test/ext/test-misc
+++ b/test/ext/test-misc
@@ -94,19 +94,6 @@ WVPASSEQ "$(cat $D/
f.new{,} | sha1sum)" "$(sha1sum <$D/
f2.new)"
WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/
a.new)"
-WVSTART "tag"
-WVFAIL bup tag -d v0.n 2>/dev/null
-WVFAIL bup tag v0.n non-existant 2>/dev/null
-WVPASSEQ "$(bup tag)" ""
-WVPASS bup tag v0.1 main
-WVPASSEQ "$(bup tag)" "v0.1"
-WVFAIL bup tag v0.1 main
-WVPASS bup tag -f v0.1 main
-WVPASS bup tag -d v0.1
-WVPASS bup tag -f -d v0.1
-WVFAIL bup tag -d v0.1
-
-
WVSTART "indexfile"
D=indexfile.tmp
INDEXFILE=tmpindexfile.tmp
diff --git a/test/ext/test-tag b/test/ext/test-tag
new file mode 100755
index 00000000..12dbc1a4
--- /dev/null
+++ b/test/ext/test-tag
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+. ./test/lib/btl.sh
+
+set -o pipefail
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+
+export BUP_DIR="$tmpdir/bup"
+export GIT_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+
+WVPASS bup init
+WVPASS cd "$tmpdir"
+
+WVPASS bup index "$top/test/sampledata"
+WVPASS bup save -n main "$top/test/sampledata"
+WVPASSEQ "$(git tag)" ''
+WVFAIL eval 'bup tag -d nope 2> >(tee log)'
+WVPASS grep "error: tag 'nope' doesn't exist" log
+WVPASSEQ "$(git tag)" ''
+WVPASS bup tag -f -d nope
+WVPASSEQ "$(git tag)" ''
+WVFAIL bup tag tag-1
+WVPASSEQ "$(git tag)" ''
+WVFAIL bup tag '' nope
+WVPASSEQ "$(git tag)" ''
+WVFAIL eval 'bup tag tag-1 nope 2> >(tee log)'
+WVPASS grep "error: commit nope not found" log
+WVPASSEQ "$(git tag)" ''
+WVFAIL eval 'bup tag .tag-1 main 2> >(tee log)'
+WVPASS grep "'.tag-1' is not a valid tag name" log
+WVPASSEQ "$(git tag)" ''
+WVPASS bup tag tag-1 main
+WVPASSEQ "$(git tag)" tag-1
+WVFAIL bup tag tag-1 main 2> log
+WVPASS grep -E "tag 'tag-1' already exists" log
+WVPASSEQ "$(git tag)" tag-1
+WVPASS bup tag -d tag-1
+WVPASSEQ "$(git tag)" ''
+
+WVPASS cd "$top"
+WVPASS rm -rf "$tmpdir"
--
2.47.3