| 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 { | 
|  | 37 | echo "wget $@" >> $LIST_OF_ACTIONS | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | function mkdir { | 
|  | 41 | if test "${1:-}" = "-p"; | 
|  | 42 | then | 
|  | 43 | echo "$2" >> $LIST_OF_DIRECTORIES | 
|  | 44 | fi | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | function unzip { | 
|  | 48 | echo "Random rubbish from unzip" | 
|  | 49 | echo "unzip $@" >> $LIST_OF_ACTIONS | 
|  | 50 | } | 
|  | 51 |  | 
|  | 52 | function rm { | 
|  | 53 | echo "rm $@" >> $LIST_OF_ACTIONS | 
|  | 54 | } | 
|  | 55 |  | 
| Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 56 | function ln { | 
|  | 57 | echo "ln $@" >> $LIST_OF_ACTIONS | 
|  | 58 | } | 
|  | 59 |  | 
| Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 60 | function [ { | 
|  | 61 | if test "${1:-}" = "-d"; | 
|  | 62 | then | 
|  | 63 | echo "[ $@" >> $LIST_OF_ACTIONS | 
|  | 64 | for directory in $(cat $LIST_OF_DIRECTORIES) | 
|  | 65 | do | 
|  | 66 | if test "$directory" = "$2" | 
|  | 67 | then | 
|  | 68 | return 0 | 
|  | 69 | fi | 
|  | 70 | done | 
|  | 71 | return 1 | 
|  | 72 | fi | 
|  | 73 | echo "Mock test does not implement the requested function" | 
|  | 74 | exit 1 | 
|  | 75 | } | 
| Mate Lakat | fe586b1 | 2013-03-28 15:02:27 +0000 | [diff] [blame] | 76 |  | 
|  | 77 | function xe { | 
|  | 78 | cat $XE_RESPONSE | 
|  | 79 | { | 
|  | 80 | for i in $(seq "$#") | 
|  | 81 | do | 
|  | 82 | eval "echo \"\$$i\"" | 
|  | 83 | done | 
|  | 84 | } >> $XE_CALLS | 
|  | 85 | } |