|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# This is the default test script that tests everything |
| 6 | +# It is not run as a scenario, but is run by other test scripts. |
| 7 | + |
| 8 | +# Optional: Import test library |
| 9 | +source dev-container-features-test-lib |
| 10 | + |
| 11 | +# check that the command is available |
| 12 | +check "help" bash -c "gel --help | grep 'Usage'" |
| 13 | + |
| 14 | +# make sure gel directories match up with our expectations |
| 15 | +check "gel cli data dir" bash -c "test \"$(gel info --get data-dir)\" = $HOME/.local/share/gel/data/" |
| 16 | +check "gel cli config dir" bash -c "test \"$(gel info --get config-dir)\" = $HOME/.config/gel/" |
| 17 | + |
| 18 | +# check that data directories exist |
| 19 | +check "~/.local/share/gel exists" bash -c "ls -la ~/.local/share | grep 'gel'" |
| 20 | +check "/dc/gel-cli/data exists" bash -c "ls -la /dc/gel-cli | grep 'data'" |
| 21 | + |
| 22 | +# check that config directories exist |
| 23 | +check "~/.config/gel exists" bash -c "ls -la ~/.config | grep 'gel'" |
| 24 | +check "/dc/gel-cli exists" bash -c "ls -la /dc/gel-cli | grep 'config'" |
| 25 | + |
| 26 | +# check that the folders are owned by the user |
| 27 | +# https://askubuntu.com/a/175060 |
| 28 | +# $USER is empty when running as root, so we use $(whoami) |
| 29 | +echo "Checking ownership of ~/.local/share/gel/data and /dc/gel-cli/data (ensure it is owned by $(whoami))" |
| 30 | + |
| 31 | +check "~/.local/share/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/gel)\" = $(whoami)" |
| 32 | +check "/dc/gel-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/data)\" = $(whoami)" |
| 33 | + |
| 34 | +check "~/.config/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gel)\" = $(whoami)" |
| 35 | +check "/dc/gel-cli/config owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/config)\" = $(whoami)" |
| 36 | + |
| 37 | +# Report result |
| 38 | +reportResults |
0 commit comments