Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
|
||
@test "hello world" { | ||
result=$(echo Hello world) | ||
[[ $result == "Hello world" ]] | ||
teardown() { | ||
rm -rf /home/git | ||
userdel git | ||
} | ||
|
||
@test "gitreceive init creates git user ready for pushes" { | ||
gitreceive init | ||
[[ -d /home/git ]] | ||
[[ -f /home/git/.ssh/authorized_keys ]] | ||
[[ -f /home/git/receiver ]] | ||
[[ "git" == "$(ls -l /home/git/receiver | awk '{print $3}')" ]] | ||
} | ||
|
||
@test "gitreceive receiver script gets tar of pushed repo" { | ||
gitreceive init | ||
cat /root/.ssh/id_rsa.pub | ssh root@localhost "gitreceive upload-key test" | ||
mkdir $BATS_TMPDIR/$BATS_TEST_NAME-push | ||
chown git $BATS_TMPDIR/$BATS_TEST_NAME-push | ||
cat <<EOF > /home/git/receiver | ||
#!/bin/bash | ||
tar -C $BATS_TMPDIR/$BATS_TEST_NAME-push -xf - | ||
EOF | ||
mkdir $BATS_TMPDIR/$BATS_TEST_NAME-repo | ||
cd $BATS_TMPDIR/$BATS_TEST_NAME-repo | ||
git init | ||
echo "foobar" > contents | ||
git add . | ||
git commit -m 'only commit' | ||
git remote add test git@localhost:test-$BATS_TEST_NUMBER | ||
git push test master | ||
[[ -f $BATS_TMPDIR/$BATS_TEST_NAME-push/contents ]] | ||
[[ "foobar" == $(cat $BATS_TMPDIR/$BATS_TEST_NAME-push/contents) ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mkdir -p /var/run/sshd && /usr/sbin/sshd | ||
|
||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys | ||
cat <<EOF > /root/.ssh/config | ||
Host localhost | ||
UserKnownHostsFile=/dev/null | ||
StrictHostKeyChecking=no | ||
EOF | ||
|
||
/usr/local/bin/bats /gitreceive.bats |