reorganize test

This commit is contained in:
Dylan Knutson
2024-04-23 14:39:35 -07:00
parent 013de9c446
commit c772661cf2
2 changed files with 5 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 185 KiB

View File

@@ -1,24 +1,21 @@
require "rest_client" require "rest_client"
require "json" require "json"
FILES = {
cat1: -> { File.new("cat1.jpg", mode: "rb") },
}
def run def run
cat1_sha256 = Digest::SHA256.file("cat1.jpg").hexdigest cat1_file = -> { File.new("fixtures/cat1.jpg", mode: "rb") }
cat1_sha256 = Digest::SHA256.file("fixtures/cat1.jpg").hexdigest
puts "store, with sha256" puts "store, with sha256"
dump_resp(RestClient.post("http://localhost:7692/store", { dump_resp(RestClient.post("http://localhost:7692/store", {
content_type: "image/jpeg", content_type: "image/jpeg",
data: FILES[:cat1].call, data: cat1_file.call,
})) }))
puts "store, without sha256:" puts "store, without sha256:"
dump_resp(RestClient.post("http://localhost:7692/store", { dump_resp(RestClient.post("http://localhost:7692/store", {
content_type: "image/jpeg", content_type: "image/jpeg",
sha256: cat1_sha256, sha256: cat1_sha256,
data: FILES[:cat1].call, data: cat1_file.call,
})) }))
puts "store, incorrect sha256:" puts "store, incorrect sha256:"
@@ -26,7 +23,7 @@ def run
RestClient.post("http://localhost:7692/store", { RestClient.post("http://localhost:7692/store", {
content_type: "image/jpeg", content_type: "image/jpeg",
sha256: "123", sha256: "123",
data: FILES[:cat1].call, data: cat1_file.call,
}) })
puts "should have thrown!" puts "should have thrown!"
rescue => e rescue => e