Class: CemAcpt::Bolt::Tests::TestList

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/bolt/tests.rb

Overview

Loads test data and provides an interface for running tests against Bolt tasks

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

current_log_config, #current_log_config, current_log_format, #current_log_format, #current_log_level, current_log_level, included, #logger, logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, #new_log_level, new_log_level, #new_logger, new_logger, verbose?, #verbose?

Constructor Details

#initialize(config = nil, run_data = nil, inventory = nil, project = nil) ⇒ TestList

Returns a new instance of TestList.



313
314
315
316
317
318
319
320
321
322
323
# File 'lib/cem_acpt/bolt/tests.rb', line 313

def initialize(config = nil, run_data = nil, inventory = nil, project = nil)
  @config = config
  @run_data = run_data
  @inventory = inventory
  @project = project
  @test_data = nil
  @tasks = []
  @tests = []
  @loaded = false
  @setup = false
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



310
311
312
# File 'lib/cem_acpt/bolt/tests.rb', line 310

def config
  @config
end

#inventoryObject

Returns the value of attribute inventory.



310
311
312
# File 'lib/cem_acpt/bolt/tests.rb', line 310

def inventory
  @inventory
end

#projectObject

Returns the value of attribute project.



310
311
312
# File 'lib/cem_acpt/bolt/tests.rb', line 310

def project
  @project
end

#run_dataObject

Returns the value of attribute run_data.



310
311
312
# File 'lib/cem_acpt/bolt/tests.rb', line 310

def run_data
  @run_data
end

#tasksObject (readonly)

Returns the value of attribute tasks.



311
312
313
# File 'lib/cem_acpt/bolt/tests.rb', line 311

def tasks
  @tasks
end

#test_dataObject (readonly)

Returns the value of attribute test_data.



311
312
313
# File 'lib/cem_acpt/bolt/tests.rb', line 311

def test_data
  @test_data
end

#testsObject (readonly)

Returns the value of attribute tests.



311
312
313
# File 'lib/cem_acpt/bolt/tests.rb', line 311

def tests
  @tests
end

Instance Method Details

#inspectObject



372
373
374
# File 'lib/cem_acpt/bolt/tests.rb', line 372

def inspect
  to_s
end

#lengthObject Also known as: count, size



362
363
364
# File 'lib/cem_acpt/bolt/tests.rb', line 362

def length
  @tests.length
end

#load!Object

Loads the test data from the Bolt test files specified in the run data



326
327
328
329
330
331
332
# File 'lib/cem_acpt/bolt/tests.rb', line 326

def load!
  return if loaded?
  raise 'Run data has not been set, assign it to the #run_data attribute first' unless @run_data

  @test_data = load_test_data(@run_data)
  @loaded = true
end

#loaded?Boolean

Returns:

  • (Boolean)


334
335
336
# File 'lib/cem_acpt/bolt/tests.rb', line 334

def loaded?
  @loaded
end

#setup!Object

Sets up the tests by loading the Bolt tasks and creating a TestWrapper for each test



339
340
341
342
343
344
345
346
# File 'lib/cem_acpt/bolt/tests.rb', line 339

def setup!
  load! unless loaded?
  @tasks = CemAcpt::Bolt::TaskList.new(@config)
  @tasks.tasks # Ensure tasks are loaded
  logger.verbose('CemAcpt::Bolt::Tests') { "TaskList metadata:\n#{@tasks..to_yaml}" }
  @tests = new_test_array(@tasks, @test_data)
  @setup = true
end

#setup?Boolean

Returns:

  • (Boolean)


348
349
350
# File 'lib/cem_acpt/bolt/tests.rb', line 348

def setup?
  @setup
end

#split_into_groups(num_groups) ⇒ Object



356
357
358
359
360
# File 'lib/cem_acpt/bolt/tests.rb', line 356

def split_into_groups(num_groups)
  raise 'Tests have not been setup, call the #setup! method first' unless setup?

  @tests.split_into_groups(num_groups)
end

#to_aObject



352
353
354
# File 'lib/cem_acpt/bolt/tests.rb', line 352

def to_a
  @tests
end

#to_sObject



368
369
370
# File 'lib/cem_acpt/bolt/tests.rb', line 368

def to_s
  "#<#{self.class}:#{object_id.to_s(16)} #{tests.join(',')}>"
end