Skip to content

Commit

Permalink
spec: Add test to validate that kits can be downloaded
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Nov 12, 2024
1 parent 04892c9 commit 2e4625f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/kit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require_relative '../lib/all'

describe 'kit_spec' do
Dir['./lib/engines/hckinstall/kits/*.json'].each do |json_file|
kit_url = AutoHCK::Models::Kit.from_json_file(json_file).download_url
if kit_url.nil?
next
end

it "Kit for #{json_file} can be downloaded" do
content = String.new

catch 1 do
HTTPClient.get_content(kit_url) do |chunk|
content << chunk
throw 1 if content.size > 32_773
end
end

file_type = nil
file_type = 'exe' if content[0..1] == 'MZ'
file_type = 'iso' if content[32_769..32_773] == 'CD001'

expect(%w[exe iso]).to include(file_type)
end
end
end

0 comments on commit 2e4625f

Please sign in to comment.