@@ -289,11 +289,10 @@ def call_automate(obj_type, obj_id, open_url_task_id = nil)
289
289
end
290
290
291
291
it "will process an array of objects" do
292
- FactoryBot . create ( :host )
293
292
FactoryBot . create ( :host )
294
293
hash = { "hosts" => Host . all }
295
294
attrs = { "Array::my_hosts" => hash [ "hosts" ] . collect { |h | "Host::#{ h . id } " } }
296
- result_str = "Array%3A%3Amy_hosts=#{ hash [ "hosts" ] . collect { |h | "Host%3A%3A#{ h . id } " } . join ( "%1F" ) } " # After URL encoding the separator "\x1F" is converted to %1F
295
+ result_str = "Array%3A%3Amy_hosts=" + hash [ "hosts" ] . collect { |h | "Host%3A%3A#{ h . id } " } . join ( "," )
297
296
extras = "MiqServer%3A%3Amiq_server=#{ miq_server_id } "
298
297
uri = "/System/Process/AUTOMATION?#{ result_str } &#{ extras } &object_name=AUTOMATION"
299
298
expect ( MiqAeEngine . create_automation_object ( "AUTOMATION" , attrs ) ) . to eq ( uri )
@@ -375,28 +374,26 @@ def call_automate(obj_type, obj_id, open_url_task_id = nil)
375
374
end
376
375
377
376
it "with an array of Vms" do
378
- result_arr = [ ]
379
- hash = { "vms" => Vm . all }
380
- result_str = "vms=#{ hash [ "vms" ] . collect { |v | v . id . to_s } . join ( "=" ) } "
381
- hash [ "vms" ] . collect { |v | result_arr . push ( v . id . to_s ) }
382
- result = MiqAeEngine . create_automation_attributes ( hash )
377
+ hash = { "vms" => Vm . all }
378
+ result_str = "Array::vms=#{ hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm::#{ v . id } " } . join ( "\x1F " ) } "
379
+ result_arr = hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm::#{ v . id } " } . join ( "\x1F " )
380
+ result = MiqAeEngine . create_automation_attributes ( hash )
383
381
expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( result_str )
384
- expect ( result [ "vms" ] ) . to eq ( result_arr )
382
+ expect ( result [ "Array:: vms" ] ) . to eq ( result_arr )
385
383
end
386
384
387
385
it "with an array containing a single Vm" do
388
- result_arr = [ ]
389
- hash = { "vms" => [ Vm . first ] }
390
- result_str = "vms=#{ hash [ "vms" ] . collect { |v | v . id . to_s } . join ( "=" ) } "
391
- hash [ "vms" ] . collect { |v | result_arr . push ( v . id . to_s ) }
392
- result = MiqAeEngine . create_automation_attributes ( hash )
386
+ hash = { "vms" => [ Vm . first ] }
387
+ result_str = "Array::vms=#{ hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm::#{ v . id } " } . join ( "\x1F " ) } "
388
+ result_arr = hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm::#{ v . id } " } . join ( "\x1F " )
389
+ result = MiqAeEngine . create_automation_attributes ( hash )
393
390
expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( result_str )
394
- expect ( result [ "vms" ] ) . to eq ( result_arr )
391
+ expect ( result [ "Array:: vms" ] ) . to eq ( result_arr )
395
392
end
396
393
397
394
it "with an empty array" do
398
395
result = MiqAeEngine . create_automation_attributes ( "vms" => [ ] )
399
- expect ( result [ "vms" ] ) . to eq ( [ ] )
396
+ expect ( result [ "Array:: vms" ] ) . to eq ( "" )
400
397
end
401
398
402
399
it "with a hash containing a single Vm" do
@@ -408,27 +405,24 @@ def call_automate(obj_type, obj_id, open_url_task_id = nil)
408
405
end
409
406
410
407
it "with an array of Hosts" do
411
- result_arr = [ ]
412
408
hash = { "hosts" => Host . all }
413
- result_str = "hosts=#{ hash [ "hosts" ] . collect { |h | h . id . to_s } . join ( "= " ) } "
414
- hash [ "hosts" ] . collect { |h | result_arr . push ( h . id . to_s ) }
415
- result = MiqAeEngine . create_automation_attributes ( hash )
409
+ result_str = "Array:: hosts=#{ hash [ "hosts" ] . collect { |h | "Host:: #{ h . id } " } . join ( "\x1F " ) } "
410
+ result_arr = hash [ "hosts" ] . collect { |h | "Host:: #{ h . id } " } . join ( " \x1F " )
411
+ result = MiqAeEngine . create_automation_attributes ( hash )
416
412
expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( result_str )
417
- expect ( result [ "hosts" ] ) . to eq ( result_arr )
413
+ expect ( result [ "Array:: hosts" ] ) . to eq ( result_arr )
418
414
end
419
415
420
416
it "with multiple arrays" do
421
- vm_result_arr = [ ]
422
- host_result_arr = [ ]
423
417
hash = { "vms" => Vm . all }
424
- vm_result_str = "vms=#{ hash [ "vms" ] . collect { |v | v . id . to_s } . join ( "= " ) } "
425
- hash [ "vms" ] . collect { |v | vm_result_arr . push ( v . id . to_s ) }
418
+ vm_result_str = "Array:: vms=#{ hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm:: #{ v . id } " } . join ( "\x1F " ) } "
419
+ vm_result_arr = hash [ "vms" ] . collect { |v | "ManageIQ::Providers::Vmware::InfraManager::Vm:: #{ v . id } " } . join ( " \x1F " )
426
420
hash [ "hosts" ] = Host . all
427
- host_result_str = "hosts=#{ hash [ "hosts" ] . collect { |h | h . id . to_s } . join ( "= " ) } "
428
- hash [ "hosts" ] . collect { |h | host_result_arr . push ( h . id . to_s ) }
429
- result = MiqAeEngine . create_automation_attributes ( hash )
430
- expect ( result [ "vms" ] ) . to eq ( vm_result_arr )
431
- expect ( result [ "hosts" ] ) . to eq ( host_result_arr )
421
+ host_result_str = "Array:: hosts=#{ hash [ "hosts" ] . collect { |h | "Host:: #{ h . id } " } . join ( "\x1F " ) } "
422
+ host_result_arr = hash [ "hosts" ] . collect { |h | "Host:: #{ h . id } " } . join ( " \x1F " )
423
+ result = MiqAeEngine . create_automation_attributes ( hash )
424
+ expect ( result [ "Array:: vms" ] ) . to eq ( vm_result_arr )
425
+ expect ( result [ "Array:: hosts" ] ) . to eq ( host_result_arr )
432
426
result_str = MiqAeEngine . create_automation_attributes_string ( hash )
433
427
expect ( result_str ) . to include ( vm_result_str )
434
428
expect ( result_str ) . to include ( host_result_str )
@@ -437,16 +431,16 @@ def call_automate(obj_type, obj_id, open_url_task_id = nil)
437
431
it "with invalid object references" do
438
432
hash = { "vms" => [ "bogus::12" ] }
439
433
result = MiqAeEngine . create_automation_attributes ( hash )
440
- expect ( result [ "vms" ] ) . to eq ( [ "bogus::12" ] )
441
- expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( "vms=bogus::12" )
434
+ expect ( result [ "Array:: vms" ] ) . to eq ( "bogus::12" )
435
+ expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( "Array:: vms=bogus::12" )
442
436
end
443
437
444
438
it "with garbage values" do
445
439
hash = { "vms" => [ "bogus::12,garbage::moreso,notevenclose" ] }
446
- bogus_arr = [ "bogus::12,garbage::moreso,notevenclose" ]
440
+ bogus_arr = "bogus::12,garbage::moreso,notevenclose"
447
441
result = MiqAeEngine . create_automation_attributes ( hash )
448
- expect ( result [ "vms" ] ) . to eq ( bogus_arr )
449
- expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( "vms=bogus::12,garbage::moreso,notevenclose" )
442
+ expect ( result [ "Array:: vms" ] ) . to eq ( bogus_arr )
443
+ expect ( MiqAeEngine . create_automation_attributes_string ( hash ) ) . to eq ( "Array:: vms=bogus::12,garbage::moreso,notevenclose" )
450
444
end
451
445
452
446
it "with a string value" do
0 commit comments