Skip to content

Commit 138a62b

Browse files
committed
build: 🔨 add test of recopy and copy in existing project
1 parent e06257e commit 138a62b

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

justfile

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ check-spelling:
3232
# Test and check that a data package can be created from the template
3333
test:
3434
#!/bin/zsh
35-
test_dir="$(pwd)/_temp"
3635
test_name="test-data-package"
36+
test_dir="$(pwd)/_temp/$test_name"
37+
template_dir="$(pwd)"
38+
commit=$(git rev-parse HEAD)
3739
rm -rf $test_dir
3840
# vcs-ref means the current commit/head, not a tag.
39-
# `.` means the current directory contains the template.
40-
uvx copier copy --vcs-ref=HEAD . $test_dir/$test_name \
41+
uvx copier copy $template_dir $test_dir \
42+
--vcs-ref=$commit \
4143
--defaults \
4244
--trust \
4345
--data package_abbrev=$test_name \
@@ -48,7 +50,39 @@ test:
4850
--data review_team="@first-last/developers" \
4951
--data github_board_number=22
5052
# Run checks in the generated test data package
51-
(cd $test_dir/$test_name && just check-python check-spelling)
53+
cd $test_dir
54+
git add .
55+
git commit -m "test: initial copy"
56+
just check-python check-spelling
57+
# TODO: Find some way to test the `update` command
58+
# Check that recopy works
59+
echo "Testing recopy command -----------"
60+
rm .cz.toml
61+
git add .
62+
git commit -m "test: recopying from the template"
63+
uvx copier recopy \
64+
--vcs-ref=$commit \
65+
--defaults \
66+
--overwrite \
67+
--trust
68+
# Check that copying onto an existing data package works
69+
echo "Using the template in an existing package command -----------"
70+
rm .cz.toml .copier-answers.yaml LICENSE-MIT.md
71+
git add .
72+
git commit -m "test: copying onto an existing package"
73+
uvx copier copy \
74+
$template_dir $test_dir \
75+
--vcs-ref=$commit \
76+
--defaults \
77+
--trust \
78+
--overwrite \
79+
--data package_abbrev=$test_name \
80+
--data package_github_repo="first-last/${test_name}" \
81+
--data author_given_name="First" \
82+
--data author_family_name="Last" \
83+
--data author_email="[email protected]" \
84+
--data review_team="@first-last/developers" \
85+
--data github_board_number=22
5286

5387
# Clean up any leftover and temporary build files
5488
cleanup:

0 commit comments

Comments
 (0)