OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 ## Include utility functions. |
| 4 . "$XDG_TEST_DIR/include/testassertions.sh" |
| 5 . "$XDG_TEST_DIR/include/testcontrol.sh" |
| 6 |
| 7 ## Test function |
| 8 test_system_as_nonroot() { |
| 9 # TODO: should follow the filename tests. |
| 10 |
| 11 ## Begin the test. |
| 12 test_start "$FUNCNAME: verify error for --mode system when run as a normal user" |
| 13 |
| 14 # Dependencies section |
| 15 test_init |
| 16 |
| 17 require_notroot |
| 18 |
| 19 use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE |
| 20 edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" |
| 21 assert_file "$INPUT_FILE" |
| 22 echo "text/x-$XDG_TEST_ID" >xdgmime.expected |
| 23 |
| 24 QUERY_FILE="testfile.xdgtest" |
| 25 echo "Some text." > $QUERY_FILE |
| 26 assert_file "$QUERY_FILE" |
| 27 |
| 28 # Verify the test type is not installed already. |
| 29 assert_exit 0 xdg-mime query filetype $QUERY_FILE |
| 30 assert_stdout |
| 31 mv out.stdout out.saved1 |
| 32 |
| 33 # Test steps section |
| 34 test_procedure |
| 35 |
| 36 assert_exit 3 xdg-mime install --mode system "$INPUT_FILE" |
| 37 assert_nostdout |
| 38 assert_stderr |
| 39 |
| 40 assert_exit 0 xdg-mime query filetype "$QUERY_FILE" |
| 41 assert_stdout out.saved1 |
| 42 assert_nostderr |
| 43 |
| 44 assert_exit 3 xdg-mime uninstall --mode system "$INPUT_FILE" |
| 45 assert_nostdout |
| 46 assert_stderr |
| 47 |
| 48 test_result |
| 49 } |
| 50 run_test test_system_as_nonroot |
OLD | NEW |