Class: NoidsClient::IntegrationTest::TestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/noids_client/integration_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ TestRunner

Returns a new instance of TestRunner.

Parameters:

  • kwargs (Hash)

    the configuration options for the NoidsServer. Note, you shouldn’t need to pass parameters if you follow the noids documentation

  • logger (Hash)

    a customizable set of options

  • noids_url (Hash)

    a customizable set of options

  • connection_class (Hash)

    a customizable set of options



133
134
135
136
137
138
139
# File 'lib/noids_client/integration_test.rb', line 133

def initialize(**kwargs)
  @logger = kwargs.fetch(:logger) { IntegrationTest.default_logger }
  logger.debug("logger: #{logger.inspect}")
  @noids_url = kwargs.fetch(:noids_url) { default_noids_url }
  @connection_class = kwargs.fetch(:connection_class) { default_connection_class }
  connect!
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



140
141
142
# File 'lib/noids_client/integration_test.rb', line 140

def connection
  @connection
end

#connection_classObject (readonly)

Returns the value of attribute connection_class.



140
141
142
# File 'lib/noids_client/integration_test.rb', line 140

def connection_class
  @connection_class
end

#loggerObject (readonly)

Returns the value of attribute logger.



140
141
142
# File 'lib/noids_client/integration_test.rb', line 140

def logger
  @logger
end

#noids_urlObject (readonly)

Returns the value of attribute noids_url.



140
141
142
# File 'lib/noids_client/integration_test.rb', line 140

def noids_url
  @noids_url
end

Instance Method Details

#runObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/noids_client/integration_test.rb', line 168

def run
  assert(connection.pool_list.empty?, "Expected connection.pool_list to be empty")
  new_pool = connection.new_pool("test", ".sddd")
  assert(new_pool, "Expected to be able to create a pool")
  assert(connection.pool_list.include?("test"), "Expected connection.pool_list to include test")
  pool = connection.get_pool("test")
  assert(pool.name == "test", "Expected pool to be named 'test'")
  assert(pool.ids_used == 0, "Expected pool to have no used IDs")
  ids = pool.mint(2)
  assert(ids.size == 2, "Expected to mint 2 ids with `pool.mint(2)`")
  assert(pool.close, "Expected close to be successful")
  assert(pool.open, "Expected to be able to re-open the pool")
  assert(pool.ids_used == 2, "Expected the previously minted ids to register as used")
  return true
end