From ae5bc51f8dad9c2efdb11922446bbae0f982fd6d Mon Sep 17 00:00:00 2001 From: Chirag-Bhatti Date: Thu, 10 Aug 2023 10:40:48 +0100 Subject: [PATCH] fix: update full import tests to check paas and non-paas config services --- spec/lib/tasks/full_import_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/lib/tasks/full_import_spec.rb b/spec/lib/tasks/full_import_spec.rb index f263f15fc..429f04609 100644 --- a/spec/lib/tasks/full_import_spec.rb +++ b/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