From dcba5e2f1aa22549822393bfb0f2d72d917d0d95 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 29 Feb 2024 18:53:16 +0200 Subject: [PATCH] rspec: Check that all jsons can be loaded into struct Signed-off-by: Kostiantyn Kostiuk --- spec/srb_json_load_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/srb_json_load_spec.rb diff --git a/spec/srb_json_load_spec.rb b/spec/srb_json_load_spec.rb new file mode 100644 index 00000000..2e2e6ea6 --- /dev/null +++ b/spec/srb_json_load_spec.rb @@ -0,0 +1,25 @@ +require 'json' + +require './lib/models/driver' + +JSON_TYPES_MAP = { + './lib/engines/hcktest/drivers/*.json' => AutoHCK::Models::Driver, +}.freeze + +describe 'srb_json_load' do + Dir['./**/*.json'].each do |json_file| + next if json_file.include? 'jtd.json' + + it json_file.to_s do + types = JSON_TYPES_MAP.filter_map { |json_files_pattern, type| type if File.fnmatch(json_files_pattern, json_file) } + + if types.empty? + pending("NO TYPE FOR #{json_file}") + raise + end + + data = types.first.from_json_file(json_file) + expect(data).not_to be_nil + end + end +end