Skip to content

Commit

Permalink
work through infra issues around migration spec
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Oct 10, 2024
1 parent 0bdcfb4 commit d20bde8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions spec/jobs/migrate_files_to_valkyrie_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:uploaded_file1) { build(:uploaded_file, file:) }
let(:fedora_file_set) { create(:file_set, title: ['Some title'], label: label, content: file) }
let(:label) { 'image.jpg' }

let(:migrated_fileset) { Hyrax.persister.save(resource: fedora_file_set.valkyrie_resource) }
let(:wings_file_set) { Hyrax.query_service.find_by(id: fedora_file_set.id) }
let(:migrated_file_set) { Hyrax.persister.save(resource: wings_file_set) }
let(:file_with_characterization) do
Hydra::PCDM::File.new.tap do |f|
f.content = 'foo'
Expand All @@ -25,21 +25,29 @@
before do
allow(Hyrax.config).to receive(:valkyrie_transition?).and_return(true)
allow(fedora_file_set).to receive(:characterization_proxy).and_return(file_with_characterization)
Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
klass_name = resource_klass_name.gsub(/Resource$/, '')
if 'FileSet' == klass_name
Hyrax::FileSet
else
klass_name.constantize
end
end

# allow(ActiveFedora::Base).to receive(:find).and_call_original
# allow(ActiveFedora::Base).to receive(:find).with(migrated_fileset.original_file.file_identifier.to_s).and_return(file_with_characterization)
# allow(FileSet).to receive(:find).with(fedora_file_set.id).and_return(fedora_file_set)
# allow(ActiveFedora::Base).to receive(:find).with(migrated_file_set.original_file.file_identifier.to_s).and_return(file_with_characterization)
# allow(File_Set).to receive(:find).with(fedora_file_set.id).and_return(fedora_file_set)
end

it "it migrates all derivatives along with a file" do
described_class.perform_now(migrated_fileset)
described_class.perform_now(migrated_file_set)

valkyrized_file_set = Hyrax.query_service.find_by(id: migrated_fileset.id)
terms = FileSet.characterization_terms - [:alpha_channels, :original_checksum]
valkyrized_file_set = Hyrax.query_service.find_by(id: migrated_file_set.id)
terms = File_Set.characterization_terms - [:alpha_channels, :original_checksum]
terms.each do |t|
expect(valkyrized_file_set.original_file.send(t)).to eq(fedora_file_set.characterization_proxy.send(t))
end
expect(valkyrized_file_set.original_file.checksum).to eq(fedora_file_set.characterization_proxy.original_checksum)
expect(valkyrized_file_set.original_file.channels).to eq(fedora_file_set.characterization_proxy.alpha_channels)
end
end

4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def clean_active_fedora_repository
# trust that clean_repo performed the clean if present
example.metadata[:clean_repo] ||
# don't run for adapters other than wings
(example.metadata[:valkyrie_adapter].present? && example.metadata[:valkyrie_adapter] != :wings_adapter)
(example.metadata[:valkyrie_adapter].present? && ![:wings_adapter, :freyja_adapter, :frigg_adapter].include?(adapter_name))
end

config.append_after(:each, type: :feature) do
Expand Down Expand Up @@ -352,7 +352,7 @@ def clean_active_fedora_repository
config.prepend_before(:example, :valkyrie_adapter) do |example|
adapter_name = example.metadata[:valkyrie_adapter]

if adapter_name == :wings_adapter
if [:wings_adapter, :freyja_adapter, :frigg_adapter].include?(adapter_name)
skip("Don't test Wings when it is dasabled") if Hyrax.config.disable_wings
else
allow(Hyrax.config).to receive(:disable_wings).and_return(true)
Expand Down

0 comments on commit d20bde8

Please sign in to comment.