groupdel.test 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
  3. # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
  4. [ -f testing.sh ] && . testing.sh
  5. if [ "$(id -u)" -ne 0 ]
  6. then
  7. echo "$SHOWSKIP: groupdel (not root)"
  8. return 2>/dev/null
  9. exit
  10. fi
  11. # Redirecting all output to /dev/null for grep and delgroup
  12. arg="&>/dev/null"
  13. #testing "name" "command" "result" "infile" "stdin"
  14. testing "group_name (text)" "groupadd toyTestGroup &&
  15. grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
  16. echo 'yes'" "yes\n" "" ""
  17. testing "group_name (alphanumeric)" "groupadd toy1Test2Group3 &&
  18. grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg &&
  19. echo 'yes'" "yes\n" "" ""
  20. testing "group_name (numeric)" "groupadd 987654321 &&
  21. grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg &&
  22. echo 'yes'" "yes\n" "" ""
  23. testing "group_name (with ./-)" "groupadd toy.1Test-2Group.3 &&
  24. grep '^toy.1Test-2Group.3:' /etc/group $arg &&
  25. groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" ""
  26. testing "group_name with group_id" "groupadd -g 49999 toyTestGroup &&
  27. grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
  28. echo 'yes'" "yes\n" "" ""