From f9fc206b1cec6267ae3da60b5593f42f072aeb2c Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 7 Nov 2024 18:46:30 +0200 Subject: [PATCH] spec: Add test to validate that kits can be downloaded Signed-off-by: Kostiantyn Kostiuk --- spec/kit_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/kit_spec.rb diff --git a/spec/kit_spec.rb b/spec/kit_spec.rb new file mode 100644 index 00000000..40e2e4bb --- /dev/null +++ b/spec/kit_spec.rb @@ -0,0 +1,23 @@ +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 + next if kit_url.nil? + + it "Kit for #{json_file} can be downloaded" do + content = String.new + + HTTPClient.get_content(kit_url) do |chunk| + content << chunk + break if content.size > 32_773 + 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