Skip to content

Commit 0b975bb

Browse files
authored
tests: add init tests (#1064)
1 parent 8113b61 commit 0b975bb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/04-init.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
WHEREAMI=$(dirname "$(realpath "$0")")
4+
export CABIN_TERM_COLOR='never'
5+
6+
test_description='Test the init command'
7+
8+
. $WHEREAMI/sharness.sh
9+
10+
test_expect_success 'cabin init' '
11+
OUT=$(mktemp -d) &&
12+
test_when_finished "rm -rf $OUT" &&
13+
mkdir $OUT/pkg &&
14+
cd $OUT/pkg &&
15+
"$WHEREAMI"/../build/cabin init 2>actual &&
16+
cat >expected <<-EOF &&
17+
Created binary (application) \`pkg\` package
18+
EOF
19+
test_cmp expected actual &&
20+
test -f cabin.toml
21+
'
22+
23+
test_expect_success 'cabin init existing' '
24+
OUT=$(mktemp -d) &&
25+
test_when_finished "rm -rf $OUT" &&
26+
mkdir $OUT/pkg &&
27+
cd $OUT/pkg &&
28+
"$WHEREAMI"/../build/cabin init 2>actual &&
29+
cat >expected <<-EOF &&
30+
Created binary (application) \`pkg\` package
31+
EOF
32+
test_cmp expected actual &&
33+
test -f cabin.toml
34+
test_must_fail "$WHEREAMI"/../build/cabin init 2>actual &&
35+
cat >expected <<-EOF &&
36+
Error: cannot initialize an existing cabin package
37+
Error: '\''cabin init'\'' failed with exit code \`1\`
38+
EOF
39+
test_cmp expected actual &&
40+
test -f cabin.toml
41+
'
42+
43+
test_done

0 commit comments

Comments
 (0)