-
Notifications
You must be signed in to change notification settings - Fork 13
/
spaceman-diff-test.sh
63 lines (47 loc) · 1.77 KB
/
spaceman-diff-test.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
#!/usr/bin/env roundup
describe "spaceman-diff: generates ascii image diffs!"
spaceman="./spaceman-diff"
run_spaceman() {
readonly output_file=$(mktemp /tmp/XXXXX)
$spaceman "$@" > "$output_file"
echo "$output_file"
}
it_shows_help_with_no_argv() {
$spaceman | grep USAGE
}
it_renders_diff() {
output_file=$(run_spaceman \
test/images/flag.png \
test/images/flag.png a190ba 100644 \
test/images/gooder-flag.png 000000 100644)
grep -F "OLD: test/images/flag.png (2000x1263 px @ 84 KB)" < "$output_file"
grep -F "NEW: test/images/gooder-flag.png (2000x1236 px @ 9 KB)" < "$output_file"
rm "$output_file"
}
it_works_with_output_filenames_containing_spaces() {
output_file=$(run_spaceman \
"test/images/flag.png" \
"test/images/flag.png" a190ba 100644 \
"test/images/with spaces.png" 000000 100644)
grep -F 'OLD: test/images/flag.png (2000x1263 px @ 84 KB)' < "$output_file"
grep -F 'NEW: test/images/with spaces.png (2000x1236 px @ 9 KB)' < "$output_file"
rm "$output_file"
}
it_works_with_input_filenames_containing_spaces() {
output_file=$(run_spaceman \
"test/images/with spaces.png" \
"test/images/with spaces.png" a190ba 100644 \
"test/images/flag.png" 000000 100644)
grep -F 'OLD: test/images/with spaces.png (2000x1236 px @ 9 KB)' < "$output_file"
grep -F 'NEW: test/images/flag.png (2000x1263 px @ 84 KB)' < "$output_file"
rm "$output_file"
}
it_works_with_small_files() {
output_file=$(run_spaceman \
"test/images/gooder-flag.png" \
"test/images/gooder-flag.png" a190ba 100644 \
"test/images/small-image.png" 000000 100644)
grep -F 'OLD: test/images/gooder-flag.png (2000x1236 px @ 9 KB)' < "$output_file"
grep -F 'NEW: test/images/small-image.png (36x38 px @ 0 KB)' < "$output_file"
rm "$output_file"
}