forked from eric/syslog_protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_logger.rb
28 lines (23 loc) · 1.61 KB
/
test_logger.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require File.expand_path('../helper', __FILE__)
describe "syslog logger" do
it "create a new logger with hostname and facility" do
lambda {@logger = SyslogProtocol::Logger.new("space_station", 'test', "local0")}.should.not.raise
end
it "hostname and facility must conform to the requirements of a Packet" do
lambda {SyslogProtocol::Logger.new("space station", "some shit", 'test test')}.should.raise ArgumentError
end
it "generates packets" do
# We have to set a time so we have a consistant timestamp to check against..
p = @logger.instance_variable_get("@packet")
p.time = Time.now
ts = p.generate_timestamp
@logger.debug("vacuum tubez are operational").should.equal "<135>#{ts} space_station test: vacuum tubez are operational"
@logger.info("firing thrusters at 13 degrees").should.equal "<134>#{ts} space_station test: firing thrusters at 13 degrees"
@logger.notice("the hyper drive has been activated").should.equal "<133>#{ts} space_station test: the hyper drive has been activated"
@logger.warn("meteorites incoming!").should.equal "<132>#{ts} space_station test: meteorites incoming!"
@logger.err("vacuum tube 3 in hyper drive failed").should.equal "<131>#{ts} space_station test: vacuum tube 3 in hyper drive failed"
@logger.crit("wing struck by a meteorite!").should.equal "<130>#{ts} space_station test: wing struck by a meteorite!"
@logger.alert("LEAKING ATMOSPHERE").should.equal "<129>#{ts} space_station test: LEAKING ATMOSPHERE"
@logger.emerg("LEAKING ASTRONAUTS WE ARE DONE").should.equal "<128>#{ts} space_station test: LEAKING ASTRONAUTS WE ARE DONE"
end
end