Permalink
Browse files

Add test that images on disk don't have duplicates

  • Loading branch information...
1 parent e2ae300 commit f73921aacdb32a0e53575c571a952127f937717a @mislav mislav committed Jul 2, 2014
Showing with 15 additions and 0 deletions.
  1. +15 −0 test/integrity_test.rb
View
@@ -1,5 +1,6 @@
require 'test_helper'
require 'json'
+require 'digest/md5'
class IntegrityTest < TestCase
test "images on disk correlate 1-1 with emojis" do
@@ -16,6 +17,20 @@ class IntegrityTest < TestCase
assert_equal 0, extra_images.size, "these images don't match any emojis: #{extra_images.inspect}"
end
+ test "images on disk have no duplicates" do
+ hashes = Hash.new { |h,k| h[k] = [] }
+ Dir["#{Emoji.images_path}/**/*.png"].each do |image_file|
+ checksum = Digest::MD5.file(image_file)
+ hashes[checksum] << image_file
+ end
+
+ hashes.each do |checksum, filenames|
+ assert_equal 1, filenames.length,
+ "These images share the same checksum: " +
+ filenames.map {|f| f.sub(Emoji.images_path, '') }.join(', ')
+ end
+ end
+
test "missing or incorrect unicodes" do
missing = source_unicode_emoji - Emoji.all.map(&:raw).compact
assert_equal 0, missing.size, missing_unicodes_message(missing)

0 comments on commit f73921a

Please sign in to comment.