Browse Source

fix: update full import tests to check paas and non-paas config services

pull/1822/head
Chirag-Bhatti 3 years ago
parent
commit
ae5bc51f8d
  1. 13
      spec/lib/tasks/full_import_spec.rb

13
spec/lib/tasks/full_import_spec.rb

@ -4,6 +4,7 @@ require "rake"
describe "full import", type: :task do
let(:instance_name) { "paas_import_instance" }
let(:paas_config_service) { instance_double(Configuration::PaasConfigurationService) }
let(:env_config_service) { instance_double(Configuration::EnvConfigurationService) }
let(:storage_service) { instance_double(Storage::S3Service) }
let(:orgs_list) { "Institution name,Id,Old Completed lettings logs,Old In progress lettings logs,Old Completed sales logs,Old In progress sales logs\norg1,1.zip,0,0,0,0\norg2,2.zip,0,0,0,0" }
@ -12,8 +13,10 @@ describe "full import", type: :task do
allow(storage_service).to receive(:write_file).and_return(nil)
allow(storage_service).to receive(:get_file_io).and_return(orgs_list)
allow(Configuration::PaasConfigurationService).to receive(:new).and_return(paas_config_service)
allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service)
allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name)
end
describe "import:generate_reports" do
@ -33,12 +36,22 @@ describe "full import", type: :task do
end
it "creates a report using given organisation csv" do
allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return("dummy")
expect(Storage::S3Service).to receive(:new).with(paas_config_service, instance_name)
expect(Imports::ImportReportService).to receive(:new).with(storage_service, CSV.parse(orgs_list, headers: true))
expect(import_report_service).to receive(:create_reports).with("some_name")
task.invoke("some_name")
end
it "creates a report using given organisation csv" do
allow(ENV).to receive(:[]).with("VCAP_SERVICES")
expect(Storage::S3Service).to receive(:new).with(env_config_service, instance_name)
expect(Imports::ImportReportService).to receive(:new).with(storage_service, CSV.parse(orgs_list, headers: true))
expect(import_report_service).to receive(:create_reports).with("some_name")
task.invoke("some_name")
end
end
end
end

Loading…
Cancel
Save