# Some utilities
pijul_switch() {
pijul fork "${1}"
pijul channel switch "${1}" 2> /dev/null
}
pijul_rec() {
pijul record --all --message "${1}" >/dev/null
}
# Alice and Bob modify the same line in the same file
order_conflict() {
pijul_switch alice
sed -i -e 's/B/X/g' file.txt
pijul_rec "alice wuz here"
pijul channel switch main 2>/dev/null
sed -i -e 's/B/Y/g' file.txt
pijul_rec "bobdor"
pijul apply "$(pijul log --channel alice --hash-only --limit 1)" 2> /dev/null
}
# Showcase a zombie line conflict - Alice inserts a line above a line
# that Bob removes
zombies() {
pijul_switch alice
sed -i -e 's/B/X\nB/g' file.txt
pijul_rec "alice does stuff"
pijul channel switch main 2>/dev/null
sed -i -e '/B/d' file.txt
pijul_rec "bob deletes"
pijul apply "$(pijul log --channel alice --hash-only --limit 1)" 2> /dev/null
}
TESTS=(
"order_conflict"
"zombies"
)
for t in "${TESTS[@]}"; do
runtest "${t}"
done