test.sh 2.5 KB

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