Class: Heroku::Kensa::DuplicateProvisionCheck

Inherits:
ApiCheck show all
Includes:
HTTPForChecks
Defined in:
lib/heroku/kensa/check.rb

Constant Summary collapse

READLEN =
1024 * 10

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods included from HTTPForChecks

#delete, #get, #post, #put, #request

Methods inherited from ApiCheck

#base_path, #callback, #create_provision_payload, #credentials, #heroku_id

Methods inherited from Check

#api_requires?, #call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url, #warning

Constructor Details

This class inherits a constructor from Heroku::Kensa::Check

Instance Method Details

#call!Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/heroku/kensa/check.rb', line 306

def call!

  json = nil
  response = nil

  code = nil
  json = nil
  reader, writer = nil

  payload = create_provision_payload

  code1, json1 = post(credentials, base_path, payload)

  payload[:uuid] = SecureRandom.uuid
  code2, json2 = post(credentials, base_path, payload)

  json1 = OkJson.decode(json1)
  json2 = OkJson.decode(json2)

  if api_requires?("many_per_app")
    check "returns different ids" do
      if json1["id"] == json2["id"]
        error "multiple provisions cannot return the same id"
      else
        true
      end
    end
  end
end