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 | |
| 15 | function mktemp { |
| 16 | if test "${1:-}" = "-d"; |
| 17 | then |
| 18 | echo "tempdir" |
| 19 | else |
| 20 | echo "tempfile" |
| 21 | fi |
| 22 | } |
| 23 | |
| 24 | function wget { |
| 25 | echo "wget $@" >> $LIST_OF_ACTIONS |
| 26 | } |
| 27 | |
| 28 | function mkdir { |
| 29 | if test "${1:-}" = "-p"; |
| 30 | then |
| 31 | echo "$2" >> $LIST_OF_DIRECTORIES |
| 32 | fi |
| 33 | } |
| 34 | |
| 35 | function unzip { |
| 36 | echo "Random rubbish from unzip" |
| 37 | echo "unzip $@" >> $LIST_OF_ACTIONS |
| 38 | } |
| 39 | |
| 40 | function rm { |
| 41 | echo "rm $@" >> $LIST_OF_ACTIONS |
| 42 | } |
| 43 | |
| 44 | function [ { |
| 45 | if test "${1:-}" = "-d"; |
| 46 | then |
| 47 | echo "[ $@" >> $LIST_OF_ACTIONS |
| 48 | for directory in $(cat $LIST_OF_DIRECTORIES) |
| 49 | do |
| 50 | if test "$directory" = "$2" |
| 51 | then |
| 52 | return 0 |
| 53 | fi |
| 54 | done |
| 55 | return 1 |
| 56 | fi |
| 57 | echo "Mock test does not implement the requested function" |
| 58 | exit 1 |
| 59 | } |