forked from integry/livecart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildtest.sh
executable file
·142 lines (103 loc) · 3.25 KB
/
buildtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
function assertEqual
{
if [ "$1" != "$2" ]
then
echo "ERROR: equals assertion failed ('$1' and '$2') at line $3"
exit
fi
}
set -x
set -e
DIR=/tmp/module/test
export PKG_ROOT=/tmp/packages
export REPO_ROOT=/tmp/repo
rm -rf $DIR
mkdir -p $DIR
cd $DIR
rm -rf $REPO_ROOT/test
# FIRST VERSION
echo -e "[Module]\n\
name = Test Module\n\
vendor = UAB Integry Systems\n\
url = http://livecart.com/\n\
version = 1.0.0\n\
free = true\n\
pkg = test" > Module.ini
echo "<?php /* Integry Systems */ echo 'test module, first stable version'; ?>" > index.php
mkdir --parents application/view
echo -e "<html>\n\
<body>this is the base file</body>\n\
</html>" > application/view/test.tpl
echo "blabla" > delete.pending
/l/build/buildnew.sh $DIR current
# SECOND VERSION
rm -f delete.pending
echo -e "[Module]\n\
name = Test Module\n\
vendor = UAB Integry Systems\n\
url = http://livecart.com/\n\
version = 1.0.1\n\
free = true\n\
pkg = test" > Module.ini
echo "<?php /* Integry Systems */ echo 'test module, second version'; ?>" > index.php
echo -e "<html>\n\
<body>this is the base file</body>\n\
<script>we forgot to add some jQuery the first time around</script>
</html>" > application/view/test.tpl
echo "some dot file" > .htaccess
/l/build/buildnew.sh $DIR current
# UPDATE FOR FIRST VERSION (STABLE BRANCH)
rm -f delete.pending
echo -e "[Module]\n\
name = Test Module\n\
vendor = UAB Integry Systems\n\
url = http://livecart.com/\n\
version = 1.0.0.1\n\
line = stable\n\
parent = 1.0.0\n\
parentline = current\n\
free = true\n\
pkg = test" > Module.ini
echo "<?php /* Integry Systems */ echo 'test module, first version, but updated'; ?>" > index.php
echo -e "<html>\n\
<body>this is the base file</body>\n\
<!-- stable version, no jQuery goodness allowed ;(( !-->
</html>" > application/view/test.tpl
/l/build/buildnew.sh $DIR stable
# THIRD VERSION
rm -f delete.pending
echo -e "[Module]\n\
name = Test Module\n\
vendor = UAB Integry Systems\n\
url = http://livecart.com/\n\
version = 1.0.2\n\
free = true\n\
line = current\n\
pkg = test" > Module.ini
echo "<?php /* Integry Systems */ echo 'test module, third version'; ?>" > index.php
echo -e "<html>\n\
<body>this is the base file</body>\n\
<script>we forgot to add some jQuery the first time around</script>
</html>" > application/view/test.tpl
echo "some dot file" > .htaccess
/l/build/buildnew.sh $DIR current
############# TESTS #############
rm -rf /tmp/buildtest && mkdir /tmp/buildtest
cd /tmp/buildtest
tar xfz /tmp/packages/updates/test/test-stable-update-1.0.0-to-1.0.0.1.tar.gz
assertEqual "`cat Module.ini | grep version`" "version = 1.0.0.1" $LINENO
# copyright
ls
assertEqual "`cat index.php | grep Copyright | wc -l`" "1"
# should be 4 changed and 1 deleted files
assertEqual "`cat update/1.0.0.1/changed | wc -l`" "3" $LINENO
assertEqual "`cat update/1.0.0.1/deleted | wc -l`" "1" $LINENO
# dot files should still be present
assertEqual "`ls .htaccess | wc -l`" "1" $LINENO
# no changed templates in 1.0.2
assertEqual "`ls $PKG_ROOT/templates/test/1.0.2 | wc -l`" "0" $LINENO
# TEST DOWNGRADE
tar xfz /tmp/packages/updates/test/test-stable-downgrade-1.0.0.1-to-1.0.0.tar.gz
assertEqual "`cat Module.ini | grep version`" "version = 1.0.0" $LINENO
echo "------------------ DONE ------------------------"