inferno_core 0.4.7.pre → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inferno/apps/cli/suite.rb +38 -0
- data/lib/inferno/apps/cli/suites.rb +13 -5
- data/lib/inferno/apps/web/controllers/test_sessions/create.rb +1 -1
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb +1 -1
- data/lib/inferno/dsl/input_output_handling.rb +2 -1
- data/lib/inferno/dsl/oauth_credentials.rb +1 -1
- data/lib/inferno/entities/test_group.rb +0 -1
- data/lib/inferno/public/bundle.js +9 -9
- data/lib/inferno/repositories/test_sessions.rb +4 -3
- data/lib/inferno/repositories.rb +13 -7
- data/lib/inferno/utils/preset_processor.rb +49 -0
- data/lib/inferno/utils/preset_template_generator.rb +6 -2
- data/lib/inferno/version.rb +1 -1
- metadata +19 -4
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'repository'
|
2
|
+
require_relative '../utils/preset_processor'
|
2
3
|
|
3
4
|
module Inferno
|
4
5
|
module Repositories
|
@@ -42,10 +43,10 @@ module Inferno
|
|
42
43
|
.map! { |result| results_repo.build_entity(result) }
|
43
44
|
end
|
44
45
|
|
45
|
-
def apply_preset(
|
46
|
+
def apply_preset(test_session, preset_id)
|
46
47
|
preset = presets_repo.find(preset_id)
|
47
|
-
preset.
|
48
|
-
session_data_repo.save(input.merge(test_session_id:))
|
48
|
+
Utils::PresetProcessor.new(preset, test_session).processed_inputs.each do |input|
|
49
|
+
session_data_repo.save(input.merge(test_session_id: test_session.id))
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
data/lib/inferno/repositories.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require_relative 'repositories/in_memory_repository'
|
2
|
-
require_relative 'repositories/repository'
|
3
2
|
require_relative 'repositories/validate_runnable_reference'
|
4
|
-
require_relative 'repositories/headers'
|
5
|
-
require_relative 'repositories/messages'
|
6
|
-
require_relative 'repositories/requests'
|
7
|
-
require_relative 'repositories/results'
|
8
3
|
require_relative 'repositories/test_groups'
|
9
|
-
require_relative 'repositories/test_runs'
|
10
|
-
require_relative 'repositories/test_sessions'
|
11
4
|
require_relative 'repositories/test_suites'
|
12
5
|
require_relative 'repositories/tests'
|
13
6
|
|
7
|
+
# Skip loading things which require the db when not necessary, such as CLI
|
8
|
+
# commands which don't need the db
|
9
|
+
unless ENV['NO_DB']&.casecmp? 'true'
|
10
|
+
require_relative 'repositories/repository'
|
11
|
+
require_relative 'repositories/headers'
|
12
|
+
require_relative 'repositories/messages'
|
13
|
+
require_relative 'repositories/requests'
|
14
|
+
require_relative 'repositories/results'
|
15
|
+
require_relative 'repositories/session_data'
|
16
|
+
require_relative 'repositories/test_runs'
|
17
|
+
require_relative 'repositories/test_sessions'
|
18
|
+
end
|
19
|
+
|
14
20
|
module Inferno
|
15
21
|
# Repositories provide an abstraction layer for dealing with entity
|
16
22
|
# persistence. All code for interacting with the database lives in
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Utils
|
3
|
+
# This class determines which values to use in a preset based on the suite
|
4
|
+
# options chosen in a session.
|
5
|
+
# @api private
|
6
|
+
class PresetProcessor
|
7
|
+
attr_accessor :preset, :session, :suite, :suite_inputs, :suite_options
|
8
|
+
|
9
|
+
def initialize(preset, session)
|
10
|
+
self.preset = preset
|
11
|
+
self.session = session
|
12
|
+
self.suite = session.test_suite
|
13
|
+
self.suite_inputs = suite.available_inputs.transform_values(&:to_hash)
|
14
|
+
self.suite_options = session.suite_options
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the list of inputs which need to be persisted, with options
|
18
|
+
# applied.
|
19
|
+
def processed_inputs
|
20
|
+
preset.inputs
|
21
|
+
.map { |input| input_for_options(input) }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def input_for_options(input)
|
27
|
+
{
|
28
|
+
name: input[:name],
|
29
|
+
value: value(input),
|
30
|
+
type: suite_inputs[input[:name].to_sym][:type]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def value(input)
|
35
|
+
value_for_option(input).presence || input[:value]
|
36
|
+
end
|
37
|
+
|
38
|
+
def value_for_option(input)
|
39
|
+
input[:value_for_options]&.find do |option_value|
|
40
|
+
option_value[:options].all? do |option|
|
41
|
+
suite_options.any? do |suite_option|
|
42
|
+
suite_option.id.to_s == option[:name] && suite_option.value == option[:value]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end&.dig(:value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -15,8 +15,12 @@ module Inferno
|
|
15
15
|
# The rubocop rule is disabled because `each_value` returns the hash,
|
16
16
|
# while `values.each` will return the array of values. We want the array
|
17
17
|
# of values here.
|
18
|
-
available_inputs.values.
|
19
|
-
|
18
|
+
available_inputs.values.map do |original_input|
|
19
|
+
{}.tap do |input|
|
20
|
+
input[:name] = original_input.delete(:name)
|
21
|
+
input[:value] = (original_input.delete(:default) if original_input.key? :default)
|
22
|
+
original_input.each { |key, value| input["_#{key}".to_sym] = value }
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
data/lib/inferno/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inferno_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-01-
|
13
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -320,6 +320,20 @@ dependencies:
|
|
320
320
|
- - "~>"
|
321
321
|
- !ruby/object:Gem::Version
|
322
322
|
version: 1.2.1
|
323
|
+
- !ruby/object:Gem::Dependency
|
324
|
+
name: tty-markdown
|
325
|
+
requirement: !ruby/object:Gem::Requirement
|
326
|
+
requirements:
|
327
|
+
- - "~>"
|
328
|
+
- !ruby/object:Gem::Version
|
329
|
+
version: 0.7.1
|
330
|
+
type: :runtime
|
331
|
+
prerelease: false
|
332
|
+
version_requirements: !ruby/object:Gem::Requirement
|
333
|
+
requirements:
|
334
|
+
- - "~>"
|
335
|
+
- !ruby/object:Gem::Version
|
336
|
+
version: 0.7.1
|
323
337
|
- !ruby/object:Gem::Dependency
|
324
338
|
name: codecov
|
325
339
|
requirement: !ruby/object:Gem::Requirement
|
@@ -625,6 +639,7 @@ files:
|
|
625
639
|
- lib/inferno/utils/markdown_formatter.rb
|
626
640
|
- lib/inferno/utils/middleware/request_logger.rb
|
627
641
|
- lib/inferno/utils/migration.rb
|
642
|
+
- lib/inferno/utils/preset_processor.rb
|
628
643
|
- lib/inferno/utils/preset_template_generator.rb
|
629
644
|
- lib/inferno/utils/static_assets.rb
|
630
645
|
- lib/inferno/version.rb
|
@@ -656,9 +671,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
656
671
|
version: 3.1.2
|
657
672
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
658
673
|
requirements:
|
659
|
-
- - "
|
674
|
+
- - ">="
|
660
675
|
- !ruby/object:Gem::Version
|
661
|
-
version:
|
676
|
+
version: '0'
|
662
677
|
requirements: []
|
663
678
|
rubygems_version: 3.3.7
|
664
679
|
signing_key:
|