One of mailcap tests failed because of changed implementation
[elinks.git] / src / mime / backend / test-mailcap-cache
blob8493fd88ca48f30ffc1b19d3e6ec0880c65d520b
1 #!/bin/sh
3 # Copyright (c) 2005 Jonas Fonseca
6 test_description='Test mailcap parsing and querying
8 This tests the parsing of various mailcap files, if they are
9 "prioritised" correctly, if the test are run correctly and
10 if querying returns the expected mailcap entry.
13 . "$TEST_LIB"
15 # Set PAGER to something recognisable since it gets appended as
16 # "|copiousoutput_handler" to entries with copiousoutput.
17 export PAGER=copiousoutput_handler
19 ################################################################
20 # Parse a simple mailcap file
22 cat > mailcap-basic <<EOF
23 # Mimetype Handler
24 text/html; elinks --force-html %s; needsterminal
25 text/enriched; richtext ; copiousoutput
26 text/*; view %s; needsterminal
27 application/postscript; ps2ascii %s ; copiousoutput
29 # Convert images to text using the netpbm tools
30 image/*; (anytopnm %s | pnmscale -xysize 200 150 | \
31 pnminvert | ppmtopgm | pgmtopbm | \
32 pbmtoascii -1x2 ) 2>&1 ; copiousoutput
33 EOF
35 mailcap-cache \
36 --path "mailcap-basic" \
37 --format "block,program" \
38 --get "text/html" \
39 --get "text/x-csh" \
40 --get "application/postscript" \
41 --get "application/foo" \
42 > output
44 cat > expected <<EOF
45 type: text/html
46 block: 1
47 program: elinks --force-html %
49 type: text/x-csh
50 block: 1
51 program: view %
53 type: application/postscript
54 block: 1
55 program: ps2ascii %
57 type: application/foo
58 EOF
60 test_expect_success \
61 'Parse simple mailcap file.' \
62 'cmp output expected' \
64 ################################################################
65 # Parse a two simple mailcap files; first one with tests
67 touch DISPLAY
69 cat > mailcap-simple-with-test <<EOF
70 application/postscript; gv %s ; test=test -e "DISPLAY" ;
71 image/*; xzgv %s ; test=test -e "DISPLAY";
72 EOF
74 mailcap-cache \
75 --path "mailcap-simple-with-test:mailcap-simple" \
76 --format "block,program" \
77 --get "image/jpeg" \
78 --get "application/postscript" \
79 > output
81 cat > expected <<EOF
82 type: image/jpeg
83 block: 0
84 program: xzgv %
86 type: application/postscript
87 block: 0
88 program: gv %
89 EOF
91 test_expect_success \
92 'Parse two simple mailcap files; first one with tests.' \
93 'cmp output expected' \
95 test_done