Method: TestData#update
- Defined in:
- lib/test_data.rb
#update(obj) ⇒ Object
Public: Updates test data.
obj - Hash from which to update test data.
Returns updated test data Hash.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/test_data.rb', line 137 def update(obj) @test_case.lock(@w_lock_obj, 1.min) do unless obj.nil? logger.debug("Updating test data: #{obj.inspect}") current_data.update(@test_case.rubify(obj, snake_case: false)) end data = @test_case.jsonify(@data, camel_case: false) resp = delay(RW_DELAY_MS) do @test_case.send(:tmc_put, "/api/jobs/#{@job}/data", json: data) end begin if @data_file.nil? @test_case.refute_nil(resp) elsif resp.nil? # Fall back to local data file, if provided path = File.join(Dir.pwd, 'conf', @data_file) File.write(path, JSON.generate(data, {indent: ' ', space: ' ', object_nl: "\n", array_nl: "\n"})) end rescue => e raise "Failed to update test data! #{e.}\n\t#{e.backtrace.join("\n\t")}" end @data end end |