summaryrefslogtreecommitdiff
path: root/tests/xdg-mime/t.system_as_nonroot
blob: 861e34d57a7f28dde94197a89a1610a06fbc1b3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

## Include utility functions.
. "$TEST_CODE_DIR/include/testassertions.sh"
. "$TEST_CODE_DIR/include/testdep.sh"
. "$TEST_CODE_DIR/include/testcontrol.sh"

## Test function
test_system_as_nonroot() {
INPUT_FILE="$TEST_CODE_DIR/xdg-mime/data/testmime.xml"
# TODO: should follow the filename tests.
QUERY_FILE="testfile.xdgtest"

## Begin the test.
test_start "$FUNCNAME: verify error for --system when run as a normal user"

# Dependencies section
test_init

assert_exit 0 test `whoami` != root

set_no_display
assert_file $INPUT_FILE
echo "Some text." > $QUERY_FILE
assert_file "$QUERY_FILE"

# Verify the test type is not installed already.
assert_exit 0 xdg-mime query filetype $QUERY_FILE
assert_stdout "$TEST_CODE_DIR/xdg-mime/data/textplain.expected"

# Test steps section
test_procedure

assert_exit 3 xdg-mime install --system "$INPUT_FILE"
assert_nostdout
assert_stderr

assert_exit 0 xdg-mime query filetype $QUERY_FILE
assert_stdout "$TEST_CODE_DIR/xdg-mime/data/textplain.expected"
assert_nostderr

assert_exit 3 xdg-mime uninstall --system "$INPUT_FILE"
assert_nostdout
assert_stderr

test_result
} 
run_test test_system_as_nonroot