Skip to content

Commit af6fa62

Browse files
committed
test harvester with until param
- harvest_time is expected to be a Time, not a String
1 parent 939e20c commit af6fa62

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/oai/harvester/harvest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def start(sites = nil, interactive = false)
3333
def harvest(site)
3434
opts = build_options_hash(@config.sites[site])
3535
if @until
36-
harvest_time = @until.to_time.utc.iso8601
36+
harvest_time = @until.to_time.utc
3737
else
3838
harvest_time = Time.now.utc
3939
end

test/harvester/tc_harvest.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,14 @@ def test_harvest_after_last
2929
last = config.sites.dig('test', 'last')
3030
assert_kind_of NilClass, last
3131
end
32+
33+
def test_harvest_with_until
34+
until_value = Time.parse(EARLIEST_FIXTURE).utc + ONE_HOUR
35+
config = OpenStruct.new(sites: { 'test' => { 'url' => 'http://localhost:3333/oai' }})
36+
OAI::Harvester::Harvest.new(config, nil, nil, until_value).start
37+
last = config.sites.dig('test', 'last')
38+
assert_kind_of Time, last
39+
assert_equal last, until_value
40+
end
3241
end
3342

0 commit comments

Comments
 (0)