Skip to content

Commit

Permalink
Merge pull request #4615 from sul-dlss/extra_valid
Browse files Browse the repository at this point in the history
Add MODS transformation validation to bin/validate-cocina
  • Loading branch information
aaron-collier authored Oct 5, 2023
2 parents 05e217c + 700c1c8 commit da0ba7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/validate-cocina
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

# Validates cocina model changes by loading each object into cocina to determine if an error is raised.
# Also, transforms the cocina model to MODS.
# This should be run on sdr-deploy since it requires using a version of cocina models that is not the latest release.
# To select the cocina model version to test, adjust the Gemfile.
# For example, gem 'cocina-models', github: 'sul-dlss/cocina-models', branch: 'test_me'
Expand Down Expand Up @@ -61,9 +62,10 @@ def validate(clazz, sample_size, processes)
in_processes: processes,
finish: ->(_, _, results) { on_finish(results, progress_bar) }) do |slice_obj_ids|
clazz.find(slice_obj_ids).map do |obj|
obj.to_cocina
cocina_obj = obj.to_cocina
Cocina::Models::Mapping::ToMods::Description.transform(cocina_obj.description, cocina_obj.externalIdentifier)
[obj.external_identifier, nil]
rescue Dry::Struct::Error, Cocina::Models::ValidationError => e
rescue StandardError => e
[obj.external_identifier, clazz.name, e.message]
end
end.flatten
Expand Down

0 comments on commit da0ba7f

Please sign in to comment.