Sha256: 3058387593e29f176a795e5306739f3f624f06426777c5370a3035e56a27e272
Contents?: true
Size: 1.28 KB
Versions: 88
Compression:
Stored size: 1.28 KB
Contents
module Inferno module Repositories module ValidateRunnableReference REFERENCE_KEYS = [:test_id, :test_group_id, :test_suite_id].freeze def validate super reference_error_message = check_runnable_reference errors.add(reference_error_message[:key], reference_error_message[:message]) if reference_error_message end def check_runnable_reference present_keys = REFERENCE_KEYS.select { |reference_key| send(reference_key) } if present_keys.length == 1 runnable_type = present_keys.first id = values[runnable_type] reference_exists = runnable_reference_exists?(runnable_type, id) return if reference_exists { key: runnable_type, message: "of #{id} does not exist" } else { key: :base, message: "must contain exactly one of 'test_id', 'test_group_id', or 'test_suite_id'" } end end def runnable_reference_exists?(type, id) repo = case type when :test_id Inferno::Repositories::Tests.new when :test_group_id Inferno::Repositories::TestGroups.new when :test_suite_id Inferno::Repositories::TestSuites.new end repo.exists? id end end end end
Version data entries
88 entries across 88 versions & 1 rubygems