Skip to content

Commit

Permalink
[api] test build failure mail
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 14, 2013
1 parent a9a4bee commit d690231
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/event/build.rb
Expand Up @@ -31,7 +31,7 @@ def faillog
log = log.slice(-19, log.length)
end
log.join
rescue ActiveXML::Transport::NotFoundError
rescue ActiveXML::Transport::Error
nil
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/views/event_mailer/build_fail.text.erb
@@ -1,11 +1,11 @@
Visit <%= url_for(controller: :package, action: :live_build_log, project: @e['project'], package: @e['package'], repository: @e['repository'], arch: @e['arch'], only_path: false, host: @host) %>
Visit <%= url_for(controller: 'webui/package', action: :live_build_log, project: @e['project'], package: @e['package'], repository: @e['repository'], arch: @e['arch'], only_path: false, host: @host) %>

Package <%= @e['project'] %>/<%= @e['package']%> failed to build in <%= @e['repository']%>/<%= @e['arch']%>

Check out the package for editing:
osc checkout <%= @e['project']%> <%= @e['package']%>
<% if @e['faillog'] -%>

<% if @e['faillog'] %>
Last lines of build log:
<%= @e['faillog'] %>
<% end %>
<% end %>
10 changes: 10 additions & 0 deletions src/api/test/fixtures/event_mailer/build_fail
@@ -0,0 +1,10 @@
Visit http://localhost/package/live_build_log/home:Iggy/TestPack/10.2/i586

Package home:Iggy/TestPack failed to build in 10.2/i586

Check out the package for editing:
osc checkout home:Iggy TestPack

--
Configure notifications at http://localhost/user/notifications
Open Build Service (http://localhost/)
14 changes: 14 additions & 0 deletions src/api/test/unit/event_mailer_test.rb
Expand Up @@ -11,4 +11,18 @@ class EventMailerTest < ActionMailer::TestCase
assert_equal read_fixture('commit_event').join, mail.body.to_s
end

test 'maintainer mails for build failure' do
# for this test we don't want fixtures to interfere
EventSubscription.delete_all

# just one subsciption
EventSubscription.create eventtype: 'Event::BuildFail', receiver_role: :maintainer, user: users(:Iggy)
Suse::Backend.start_test_backend

mail = EventMailer.event(users(:Iggy), events(:build_failure_for_iggy))
assert_equal "Build failure of home:Iggy/TestPack in 10.2/i586", mail.subject
assert_equal ["Iggy@pop.org"], mail.to
assert_equal read_fixture('build_fail').join, mail.body.to_s

end
end

0 comments on commit d690231

Please sign in to comment.