Class: TestRunner::TestConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/test-runner/test_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test, config_path:, system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) ⇒ TestConfig

Returns a new instance of TestConfig.

Parameters:

  • test (Test)
  • config_path (String)


19
20
21
22
23
24
# File 'lib/test-runner/test_config.rb', line 19

def initialize(test, config_path:, system: NixCli::DEFAULT_SYSTEM, test_config_path: nil)
  @test = test
  @nix = NixCli.new(system:, test_config_path:)
  @config_path = config_path
  @config = {}
end

Instance Attribute Details

#config_pathTest (readonly)

Returns:



15
16
17
# File 'lib/test-runner/test_config.rb', line 15

def config_path
  @config_path
end

#testTest (readonly)

Returns:



15
16
17
# File 'lib/test-runner/test_config.rb', line 15

def test
  @test
end

Class Method Details

.build(test, config_path:, system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) ⇒ Object

Parameters:

  • test (Test)
  • config_path (String)


8
9
10
11
12
# File 'lib/test-runner/test_config.rb', line 8

def self.build(test, config_path:, system: NixCli::DEFAULT_SYSTEM, test_config_path: nil)
  tc = new(test, system:, test_config_path:, config_path:)
  tc.build
  tc
end

Instance Method Details

#[](key) ⇒ Object



32
33
34
# File 'lib/test-runner/test_config.rb', line 32

def [](key)
  @config[key]
end

#buildObject



26
27
28
29
30
# File 'lib/test-runner/test_config.rb', line 26

def build
  FileUtils.mkdir_p(File.dirname(config_path))
  @nix.build_test_json(test.path, config_path)
  @config = JSON.parse(File.read(config_path))
end

#dig(*keys) ⇒ Object



36
37
38
# File 'lib/test-runner/test_config.rb', line 36

def dig(*keys)
  @config.dig(*keys)
end