Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | test ! -e "$LIST_OF_ACTIONS" && { |
| 4 | echo "Mocking is not set up properly." |
| 5 | echo "LIST_OF_ACTIONS should point to an existing file." |
| 6 | exit 1 |
| 7 | } |
| 8 | |
| 9 | test ! -e "$LIST_OF_DIRECTORIES" && { |
| 10 | echo "Mocking is not set up properly." |
| 11 | echo "LIST_OF_DIRECTORIES should point to an existing file." |
| 12 | exit 1 |
| 13 | } |
| 14 | |
Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 15 | test ! -e "$XE_RESPONSE" && { |
| 16 | echo "Mocking is not set up properly." |
| 17 | echo "XE_RESPONSE should point to an existing file." |
| 18 | exit 1 |
| 19 | } |
| 20 | |
| 21 | test ! -e "$XE_CALLS" && { |
| 22 | echo "Mocking is not set up properly." |
| 23 | echo "XE_CALLS should point to an existing file." |
| 24 | exit 1 |
| 25 | } |
| 26 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 27 | function mktemp { |
| 28 | if test "${1:-}" = "-d"; |
| 29 | then |
| 30 | echo "tempdir" |
| 31 | else |
| 32 | echo "tempfile" |
| 33 | fi |
| 34 | } |
| 35 | |
| 36 | function wget { |
Euan Harris | 6f00171 | 2013-07-10 16:30:31 +0100 | [diff] [blame] | 37 | if [[ $@ =~ "failurl" ]]; then |
Mate Lakat | 2781f3b | 2013-12-11 13:41:54 +0000 | [diff] [blame] | 38 | return 1 |
Euan Harris | 6f00171 | 2013-07-10 16:30:31 +0100 | [diff] [blame] | 39 | fi |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 40 | echo "wget $@" >> $LIST_OF_ACTIONS |
| 41 | } |
| 42 | |
| 43 | function mkdir { |
| 44 | if test "${1:-}" = "-p"; |
| 45 | then |
| 46 | echo "$2" >> $LIST_OF_DIRECTORIES |
| 47 | fi |
| 48 | } |
| 49 | |
| 50 | function unzip { |
| 51 | echo "Random rubbish from unzip" |
| 52 | echo "unzip $@" >> $LIST_OF_ACTIONS |
| 53 | } |
| 54 | |
| 55 | function rm { |
| 56 | echo "rm $@" >> $LIST_OF_ACTIONS |
| 57 | } |
| 58 | |
Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 59 | function ln { |
| 60 | echo "ln $@" >> $LIST_OF_ACTIONS |
| 61 | } |
| 62 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 63 | function [ { |
| 64 | if test "${1:-}" = "-d"; |
| 65 | then |
| 66 | echo "[ $@" >> $LIST_OF_ACTIONS |
| 67 | for directory in $(cat $LIST_OF_DIRECTORIES) |
| 68 | do |
| 69 | if test "$directory" = "$2" |
| 70 | then |
| 71 | return 0 |
| 72 | fi |
| 73 | done |
| 74 | return 1 |
| 75 | fi |
Mate Lakat | 085abd8 | 2013-12-11 12:21:12 +0000 | [diff] [blame] | 76 | echo "Mock test does not implement the requested function: ${1:-}" |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 77 | exit 1 |
| 78 | } |
Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 79 | |
Mate Lakat | 2781f3b | 2013-12-11 13:41:54 +0000 | [diff] [blame] | 80 | function die_with_error { |
| 81 | echo "$1" >> $DEAD_MESSAGES |
| 82 | } |
| 83 | |
Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 84 | function xe { |
| 85 | cat $XE_RESPONSE |
| 86 | { |
| 87 | for i in $(seq "$#") |
| 88 | do |
| 89 | eval "echo \"\$$i\"" |
| 90 | done |
| 91 | } >> $XE_CALLS |
| 92 | } |