Skip to content

Commit

Permalink
Add an integration-testing script (per GlobusClient approach)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo committed Sep 29, 2023
1 parent dc978e1 commit 6112115
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Integration Testing

To test that the gem works against the Folio APIs, run `api_test.rb` via:

```shell
# NOTE: This is bash syntax, YMMV
$ export OKAPI_PASSWORD=$(vault kv get --field=content puppet/application/folio/stage/app_sdr_password)
$ export OKAPI_TENANT=sul
$ export OKAPI_USER=app_sdr
$ export OKAPI_URL=https://okapi-stage.stanford.edu
# NOTE: The args below are a list of MARC files
$ bundle exec ruby ./api_test.rb /path/to/marc/files/test.mrc /another/marc/file/at/foobar.marc
```

Inspect the output and make sure there are no errors.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sul-dlss/folio_client.
38 changes: 38 additions & 0 deletions api_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "folio_client"

marc_files = *ARGV

client =
FolioClient.configure(
url: ENV["OKAPI_URL"],
login_params: {
username: ENV["OKAPI_USER"],
password: ENV["OKAPI_PASSWORD"]
},
okapi_headers: {
"X-Okapi-Tenant": ENV["OKAPI_TENANT"],
"User-Agent": "folio_client gem (testing)"
}
)

pp(client.fetch_marc_hash(instance_hrid: "a666"))

puts client.fetch_marc_xml(instance_hrid: "a666")
puts client.fetch_marc_xml(barcode: "20503330279")

records = marc_files.flat_map do |marc_file_path|
MARC::Reader.new(marc_file_path).to_a
end

data_importer =
client.data_import(
records: records,
job_profile_id: "e34d7b92-9b83-11eb-a8b3-0242ac130003",
job_profile_name: "Default - Create instance and SRS MARC Bib"
)

puts data_importer.wait_until_complete
puts data_importer.instance_hrids

0 comments on commit 6112115

Please sign in to comment.