|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Simple script for testing all functions of AM |
| 4 | + |
| 5 | +n=0 |
| 6 | +((n++)) |
| 7 | +function _check() { |
| 8 | + printf '%s - %s\n\n%s' "${1}" "${3}" "$(am ${2} || echo "FAIL: ${1}" && exit $n)" |
| 9 | +} |
| 10 | + |
| 11 | +function list_apps() { |
| 12 | + am list |
| 13 | +} |
| 14 | + |
| 15 | +function _pick_app() { |
| 16 | + randomApp=$(cut -d' ' -f2 < /opt/am/x86_64-apps | shuf -n 1) |
| 17 | +} |
| 18 | + |
| 19 | +# Test needs: Items in brackets [] are optional |
| 20 | +# Use '' or "" for arguments with more words! |
| 21 | +#_check <Name of test> <command> [Short info] |
| 22 | + |
| 23 | +_pick_app |
| 24 | +printf '\n-----------------------------------------------------------------------------\n\n\t\tAM testing started\n\n-----------------------------------------------------------------------------\n\n' |
| 25 | +_check am am 'no argument' |
| 26 | + |
| 27 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 28 | +_check version version |
| 29 | + |
| 30 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 31 | +_check 'files --less' 'files --less' 'Number of installed apps' |
| 32 | + |
| 33 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 34 | +_check "install ${randomApp}" "install ${randomApp}" "Install random app" |
| 35 | + |
| 36 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 37 | +_check 'files --less' 'files --less' 'Installed apps' |
| 38 | + |
| 39 | +#_check files files 'Installed apps' |
| 40 | + |
| 41 | +#_check 'files --byname' 'files --byname' 'Installed apps by name' |
| 42 | + |
| 43 | +#_check help help 'Help message' |
| 44 | + |
| 45 | +#_check 'update apps' 'update --apps' 'Update Apps' |
| 46 | + |
| 47 | +#_check list list 'List available Apps' |
| 48 | + |
| 49 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 50 | +_check "remove ${randomApp}" "remove ${randomApp}" "Remove random app" |
| 51 | + |
| 52 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 53 | +_check 'files --less' 'files --less' 'Number of installed apps' |
| 54 | + |
| 55 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 56 | + |
| 57 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 58 | + |
| 59 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 60 | + |
| 61 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 62 | + |
| 63 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 64 | + |
| 65 | +printf '\n-----------------------------------------------------------------------------\n\n' |
| 66 | + |
| 67 | +printf '\n-----------------------------------------------------------------------------\n\n\t\tAM testing Finished\n\n-----------------------------------------------------------------------------\n\n' |
| 68 | + |
| 69 | +exit 0 |
0 commit comments