Skip to content

Commit

Permalink
πŸ› fix retries search
Browse files Browse the repository at this point in the history
  • Loading branch information
r74tech committed Oct 8, 2024
1 parent 407f5a0 commit 3235918
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions wikidotrb/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ gem "base64"
gem "mutex_m"

group :test do
gem 'rspec_junit_formatter'
end
gem "rspec_junit_formatter"
end
14 changes: 11 additions & 3 deletions wikidotrb/lib/wikidotrb/module/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,17 @@ def self.create_or_edit(site:, fullname:, page_id: nil, title: "", source: "", c
)
end

# Confirming page creation
res = PageCollection.search_pages(site, Wikidotrb::Module::SearchPagesQuery.new(fullname: fullname))
raise Wikidotrb::Common::Exceptions::NotFoundException, "Page creation failed: #{fullname}" if res.empty?
retries = 3
begin
res = PageCollection.search_pages(site, Wikidotrb::Module::SearchPagesQuery.new(fullname: fullname))
raise Wikidotrb::Common::Exceptions::NotFoundException, "Page creation failed: #{fullname}" if res.empty?
rescue Wikidotrb::Common::Exceptions::NotFoundException => e
retries -= 1
raise e unless retries.positive?

sleep @site.config.retry_interval
retry
end

res[0]
end
Expand Down
25 changes: 11 additions & 14 deletions wikidotrb/spec/module/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@
force_edit: true
)
rescue Wikidotrb::Common::Exceptions::TargetErrorException => e
if e.message.include?("locked")
sleep(1)
retry
else
raise e
end
raise e unless e.message.include?("locked")

sleep(1)
retry
end
expect(page.fullname).to eq(@test_page_name)
expect(page.title).to eq(test_page_title)
Expand All @@ -84,16 +82,15 @@
force_edit: true
)

# γƒšγƒΌγ‚Έγ‚’η·¨ι›†
new_source = "This is the updated content of the page."
page.edit(source: new_source, comment: "Updating the test page", force_edit: true)
# γƒšγƒΌγ‚Έγ‚’η·¨ι›†
new_source = "This is the updated content of the page."
page.edit(source: new_source, comment: "Updating the test page", force_edit: true)

# η·¨ι›†γŒζ­£γ—γεζ˜ γ•γ‚Œγ¦γ„γ‚‹γ‹η’Ίθͺ
updated_page = site.page.get(@test_page_name)
expect(updated_page.source.wiki_text).to eq(new_source)
# η·¨ι›†γŒζ­£γ—γεζ˜ γ•γ‚Œγ¦γ„γ‚‹γ‹η’Ίθͺ
updated_page = site.page.get(@test_page_name)
expect(updated_page.source.wiki_text).to eq(new_source)
end
end
end


context "Searching for pages" do
it "search" do
Expand Down

0 comments on commit 3235918

Please sign in to comment.