Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
driskell committed Dec 13, 2014
1 parent c578706 commit 59c5799
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions spec/courier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@
"log level": "debug",
"log syslog": false,
"log stdout": false,
"log file": "#{TEMP_PATH}/logs/log.log"
"log file": "#{TEMP_PATH}/logs/log.log",
"host": "custom.hostname.local"
},
"network": {
"ssl ca": "#{@ssl_cert.path}",
Expand All @@ -641,7 +642,7 @@
f.log 5000

# Receive and check
receive_and_check
receive_and_check host: 'custom.hostname.local'

shutdown
expect(File.file?("#{TEMP_PATH}/logs/log.log")).to be true
Expand Down
9 changes: 7 additions & 2 deletions spec/lib/helpers/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def receive_and_check(args = {}, &block)
total: nil,
check: true,
check_file: true,
check_order: true
check_order: true,
host: nil
}.merge!(args)

# Quick check of the total events we are expecting - but allow time to receive them
Expand All @@ -170,6 +171,10 @@ def receive_and_check(args = {}, &block)
total = args[:total]
end

args.delete_if do |k,v|
v.nil?
end

orig_total = total
check = args[:check]

Expand All @@ -189,7 +194,7 @@ def receive_and_check(args = {}, &block)
if block.nil?
found = @files.find do |f|
next unless f.pending?
f.logged?(check_file: args[:check_file], check_order: args[:check_order], event: e)
f.logged?(event: e, **args)
end
expect(found).to_not be_nil, "Event received not recognised: #{e}"
else
Expand Down
9 changes: 5 additions & 4 deletions spec/lib/logfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ def pending?

def logged?(args = {})
args = {
event: { 'host' => nil },
check_file: true,
check_order: true
event: { 'host' => nil },
check_file: true,
check_order: true,
host: @host
}.merge!(args)

event = args[:event]

return false if event['host'] != @host
return false if event['host'] != args[:host]
return false if args[:check_file] && event['path'] != @orig_path

if args[:check_order]
Expand Down

0 comments on commit 59c5799

Please sign in to comment.