Files
curriculum/1.solar-system/1.welcome/16.the-pusher/testing/test.sh

28 lines
1006 B
Bash

#!/bin/bash
mkdir -p local-repo
(
cd local-repo
git init -q -b main
git config user.name "Cadet Vega"
git config user.email "cadet.vega@learnroom.local"
echo "# Mission" > README.md
git add README.md; git commit -q -m "initial commit"
echo "Day 1 log" > log.txt
git add log.txt; git commit -q -m "add log"
)
git init -q --bare remote.git
bash solution.sh > /dev/null 2>&1
N=0
report() { N=$((N+1)); if [ "$1" = "0" ]; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi; }
ORIGIN_URL=$(git -C local-repo remote get-url origin 2>/dev/null)
[ -n "$ORIGIN_URL" ]; report $? "'origin' remote configured on local-repo"
LOCAL_COUNT=$(git -C local-repo log --oneline main 2>/dev/null | wc -l | tr -d ' ')
REMOTE_COUNT=$(git -C remote.git log --oneline main 2>/dev/null | wc -l | tr -d ' ')
[ -n "$REMOTE_COUNT" ] && [ "$REMOTE_COUNT" != "0" ]; report $? "remote.git has commits on main"
[ "$LOCAL_COUNT" = "$REMOTE_COUNT" ]; report $? "remote.git has same number of commits as local-repo"