Skip to content

Commit 6520e6b

Browse files
authored
tests: add more new tests (#1061)
1 parent ba50c95 commit 6520e6b

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/Cmd/New.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ newMain(const std::span<const std::string_view> args) {
149149
}
150150

151151
if (const auto err = validatePackageName(packageName)) {
152-
logger::error("package names {}: `{}`", err.value(), packageName);
152+
logger::error("package name {}: `{}`", err.value(), packageName);
153153
return EXIT_FAILURE;
154154
}
155155

tests/02-new.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test cabin new'
77

88
. $WHEREAMI/sharness.sh
99

10-
test_expect_success 'cabin new hello_world' '
10+
test_expect_success 'cabin new bin hello_world' '
1111
test_when_finished "rm -rf hello_world" &&
1212
"$WHEREAMI"/../build/cabin new hello_world 2>actual &&
1313
(
@@ -25,4 +25,41 @@ EOF
2525
test_cmp expected actual
2626
'
2727

28+
test_expect_success 'cabin new lib hello_world' '
29+
test_when_finished "rm -rf hello_world" &&
30+
"$WHEREAMI"/../build/cabin new --lib hello_world 2>actual &&
31+
(
32+
test -d hello_world &&
33+
cd hello_world &&
34+
test -d .git &&
35+
test -f .gitignore &&
36+
test -f cabin.toml &&
37+
test -d include
38+
) &&
39+
cat >expected <<-EOF &&
40+
Created library \`hello_world\` package
41+
EOF
42+
test_cmp expected actual
43+
'
44+
45+
test_expect_success 'cabin new empty' '
46+
test_must_fail "$WHEREAMI"/../build/cabin new 2>actual &&
47+
cat >expected <<-EOF &&
48+
Error: package name must not be empty: \`\`
49+
Error: '\''cabin new'\'' failed with exit code \`1\`
50+
EOF
51+
test_cmp expected actual
52+
'
53+
54+
test_expect_success 'cabin new existing' '
55+
test_when_finished "rm -rf existing" &&
56+
mkdir -p existing &&
57+
test_must_fail "$WHEREAMI"/../build/cabin new existing 2>actual &&
58+
cat >expected <<-EOF &&
59+
Error: directory \`existing\` already exists
60+
Error: '\''cabin new'\'' failed with exit code \`1\`
61+
EOF
62+
test_cmp expected actual
63+
'
64+
2865
test_done

0 commit comments

Comments
 (0)