Skip to content

Commit

Permalink
[yegor256#369] add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbao01 committed Jul 20, 2022
1 parent 43fec9e commit 6d32e9b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test-assets/puzzles/notify-unknown-open-issues.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<!--
(The MIT License)
Copyright (c) 2016-2022 Yegor Bugayenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<puzzles>
<puzzle alive="true">
<id>1-abcdef</id>
<issue>5</issue>
<children>
<puzzle alive="true">
<id>5-abcdef</id>
<issue href="//issue/125">unknown</issue>
<ticket>5</ticket>
</puzzle>
</children>
</puzzle>
</puzzles>
16 changes: 16 additions & 0 deletions test/test_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def test_notification_on_one_new_puzzle
)
end

def test_notification_unknown_issue
tickets = Tickets.new
xml = File.open('test-assets/puzzles/notify-unknown-open-issues.xml') do |f|
Nokogiri::XML(f)
end
Diff.new(Nokogiri::XML('<puzzles/>'), xml).notify(tickets)
assert(
tickets.messages.length == 1,
"Incorrect number of messages: #{tickets.messages.length}"
)
assert(
tickets.messages[0] == '5 the puzzle [#125](//issue/125) is still not solved.',
"Text is wrong: #{tickets.messages[0]}"
)
end

def test_notification_on_two_new_puzzles
tickets = Tickets.new
Diff.new(
Expand Down

0 comments on commit 6d32e9b

Please sign in to comment.