blob: b00655873c5fb92b55ccfa4ff2f8dd9dd9162116 [file] [log] [blame]
Mate Lakat57e3da92013-03-22 16:34:05 +00001#!/bin/bash
2
3test ! -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
9test ! -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
15function mktemp {
16 if test "${1:-}" = "-d";
17 then
18 echo "tempdir"
19 else
20 echo "tempfile"
21 fi
22}
23
24function wget {
25 echo "wget $@" >> $LIST_OF_ACTIONS
26}
27
28function mkdir {
29 if test "${1:-}" = "-p";
30 then
31 echo "$2" >> $LIST_OF_DIRECTORIES
32 fi
33}
34
35function unzip {
36 echo "Random rubbish from unzip"
37 echo "unzip $@" >> $LIST_OF_ACTIONS
38}
39
40function rm {
41 echo "rm $@" >> $LIST_OF_ACTIONS
42}
43
44function [ {
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}