blob: 6da6acbba77391f52e86bef995f58a544fa86760 [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
Mate Lakatfe586b12013-03-28 15:02:27 +000015test ! -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
21test ! -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 Lakat57e3da92013-03-22 16:34:05 +000027function mktemp {
28 if test "${1:-}" = "-d";
29 then
30 echo "tempdir"
31 else
32 echo "tempfile"
33 fi
34}
35
36function wget {
37 echo "wget $@" >> $LIST_OF_ACTIONS
38}
39
40function mkdir {
41 if test "${1:-}" = "-p";
42 then
43 echo "$2" >> $LIST_OF_DIRECTORIES
44 fi
45}
46
47function unzip {
48 echo "Random rubbish from unzip"
49 echo "unzip $@" >> $LIST_OF_ACTIONS
50}
51
52function rm {
53 echo "rm $@" >> $LIST_OF_ACTIONS
54}
55
Mate Lakatfe586b12013-03-28 15:02:27 +000056function ln {
57 echo "ln $@" >> $LIST_OF_ACTIONS
58}
59
Mate Lakat57e3da92013-03-22 16:34:05 +000060function [ {
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 Lakatfe586b12013-03-28 15:02:27 +000076
77function xe {
78 cat $XE_RESPONSE
79 {
80 for i in $(seq "$#")
81 do
82 eval "echo \"\$$i\""
83 done
84 } >> $XE_CALLS
85}