reorganize test
This commit is contained in:
0
test/cat1.jpg → test/fixtures/cat1.jpg
vendored
0
test/cat1.jpg → test/fixtures/cat1.jpg
vendored
|
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 185 KiB |
13
test/test.rb
13
test/test.rb
@@ -1,24 +1,21 @@
|
||||
require "rest_client"
|
||||
require "json"
|
||||
|
||||
FILES = {
|
||||
cat1: -> { File.new("cat1.jpg", mode: "rb") },
|
||||
}
|
||||
|
||||
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"
|
||||
dump_resp(RestClient.post("http://localhost:7692/store", {
|
||||
content_type: "image/jpeg",
|
||||
data: FILES[:cat1].call,
|
||||
data: cat1_file.call,
|
||||
}))
|
||||
|
||||
puts "store, without sha256:"
|
||||
dump_resp(RestClient.post("http://localhost:7692/store", {
|
||||
content_type: "image/jpeg",
|
||||
sha256: cat1_sha256,
|
||||
data: FILES[:cat1].call,
|
||||
data: cat1_file.call,
|
||||
}))
|
||||
|
||||
puts "store, incorrect sha256:"
|
||||
@@ -26,7 +23,7 @@ def run
|
||||
RestClient.post("http://localhost:7692/store", {
|
||||
content_type: "image/jpeg",
|
||||
sha256: "123",
|
||||
data: FILES[:cat1].call,
|
||||
data: cat1_file.call,
|
||||
})
|
||||
puts "should have thrown!"
|
||||
rescue => e
|
||||
|
||||
Reference in New Issue
Block a user