forked from metacpan/metacpan-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpantesters_mini_db_for_testing
executable file
·63 lines (48 loc) · 1.13 KB
/
cpantesters_mini_db_for_testing
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
#!/bin/bash
cd `dirname "$0"`
cd ..
url=http://devel.cpantesters.org/release/release.db.bz2
in=t/var/tmp/cpantesters-release.db
out=t/var/cpantesters-release-fake.db
table=release
download_original () {
test -s "$in" || \
wget -O "$in.bz2" "$url"
test -f "$in.bz2" && \
bunzip2 "$in.bz2"
rm -f "$out" "$out.bz2"
}
finish () {
# Compress the db like cpantesters does.
bzip2 "$out"
}
sqlout () { sqlite3 "$out"; }
sql () {
sqlite3 "$in" | sqlout
}
dist_version () {
local dist="$1" version="$2"
cat <<SQL | sql
.mode insert $table
select * from release where dist = '$dist' and version = '$version';
SQL
}
fake_dist () {
echo "INSERT INTO $table VALUES('$1', '$2', $3, $4, $5, $6);" | sqlout
}
populate_db () {
# Create tables.
echo .schema | sql
# Get test cases from real data.
dist_version 'Devel-GoFaster' '0.000'
dist_version 'P' '1.0.20'
dist_version 'IPsonar' '0.29'
dist_version 'weblint' '++-1.15'
dist_version 'WWW-Tumblr' ''
# Add records for our fake dists.
fake_dist 'Some' '1.00-TRIAL' 4 3 2 1
}
# main
download_original
populate_db
finish