Skip to content

Commit

Permalink
Add test for #size
Browse files Browse the repository at this point in the history
  • Loading branch information
m-o-e committed May 3, 2020
1 parent f22f704 commit ea551d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rucksack
version: 1.0.3
version: 1.0.4
description: Attach static files to your compiled crystal binary and access them at runtime.

authors:
Expand Down
4 changes: 2 additions & 2 deletions src/rucksack.cr
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ class Rucksack

def checksum : Slice(UInt8)
c = Checksummer.new
File.open(@path) do |fd|
::File.open(@path) do |fd|
IO.copy(fd, c)
end
c.digest
end

def size : UInt64
File.size(@path)
::File.size(@path)
end
end

Expand Down
8 changes: 7 additions & 1 deletion test/test.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ checksums.each do |file, checksum|
rucksack(file).read(c)
if checksum != c.digest
puts
puts "ERROR: #{file}"
puts "ERROR: Checksum mismatch #{file}"
exit 1
end

if rucksack(file).size != File.size(file)
puts
puts "ERROR: Size mismatch #{file}"
exit 1
end
end
Expand Down

0 comments on commit ea551d1

Please sign in to comment.