Permalink
Browse files

Adding test cases

  • Loading branch information...
1 parent b77492b commit e1479e27fd6347718559cac0ae7e25318a440f9f @lusis committed Sep 10, 2011
Showing with 42 additions and 0 deletions.
  1. +7 −0 Rakefile
  2. BIN test/fixtures/chunked_10_37.chunk
  3. BIN test/fixtures/chunked_11_37.chunk
  4. BIN test/fixtures/chunked_12_37.chunk
  5. BIN test/fixtures/chunked_13_37.chunk
  6. BIN test/fixtures/chunked_14_37.chunk
  7. BIN test/fixtures/chunked_15_37.chunk
  8. BIN test/fixtures/chunked_16_37.chunk
  9. BIN test/fixtures/chunked_17_37.chunk
  10. BIN test/fixtures/chunked_18_37.chunk
  11. BIN test/fixtures/chunked_19_37.chunk
  12. BIN test/fixtures/chunked_1_37.chunk
  13. BIN test/fixtures/chunked_20_37.chunk
  14. BIN test/fixtures/chunked_21_37.chunk
  15. BIN test/fixtures/chunked_22_37.chunk
  16. BIN test/fixtures/chunked_23_37.chunk
  17. BIN test/fixtures/chunked_24_37.chunk
  18. BIN test/fixtures/chunked_25_37.chunk
  19. BIN test/fixtures/chunked_26_37.chunk
  20. BIN test/fixtures/chunked_27_37.chunk
  21. BIN test/fixtures/chunked_28_37.chunk
  22. BIN test/fixtures/chunked_29_37.chunk
  23. BIN test/fixtures/chunked_2_37.chunk
  24. BIN test/fixtures/chunked_30_37.chunk
  25. BIN test/fixtures/chunked_31_37.chunk
  26. BIN test/fixtures/chunked_32_37.chunk
  27. BIN test/fixtures/chunked_33_37.chunk
  28. BIN test/fixtures/chunked_34_37.chunk
  29. BIN test/fixtures/chunked_35_37.chunk
  30. BIN test/fixtures/chunked_36_37.chunk
  31. BIN test/fixtures/chunked_37_37.chunk
  32. BIN test/fixtures/chunked_3_37.chunk
  33. BIN test/fixtures/chunked_4_37.chunk
  34. BIN test/fixtures/chunked_5_37.chunk
  35. BIN test/fixtures/chunked_6_37.chunk
  36. BIN test/fixtures/chunked_7_37.chunk
  37. BIN test/fixtures/chunked_8_37.chunk
  38. BIN test/fixtures/chunked_9_37.chunk
  39. +17 −0 test/tc_chunked.rb
  40. +14 −0 test/tc_unchunked.rb
  41. +4 −0 test/ts_all.rb
View
@@ -1 +1,8 @@
require "bundler/gem_tasks"
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.test_files = FileList['test/ts_*.rb']
+ t.verbose = true
+end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -0,0 +1,17 @@
+$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+require 'gelfd'
+require 'json'
+require 'test/unit'
+
+class TestChhunkedGelf < Test::Unit::TestCase
+ JSON_MESSAGE = '{"version":"1.0","host":"somehost","level":"debug","facility":"myapp","short_message":"boom","full_message":"something failed horribly","file":"myapp.rb","timestamp":1315539095.041,"line":105}'
+ FIXTURE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
+ def test_chunked_message
+ files = Dir.glob("#{FIXTURE_PATH}/*.chunk")
+ files.each do |file|
+ data = File.open("#{file}", "rb") {|f| f.read}
+ @t = Gelfd::Parser.parse(data)
+ end
+ assert_equal(JSON_MESSAGE, @t)
+ end
+end
View
@@ -0,0 +1,14 @@
+$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+require 'gelfd'
+require 'json'
+require 'test/unit'
+
+class TestUnchunkedGelf < Test::Unit::TestCase
+ FIXTURE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
+
+ def test_unchunked_message
+ data = File.open("#{FIXTURE_PATH}/unchunked.zl", "rb") {|f| f.read}
+ t = Gelfd::Parser.parse(data)
+ assert_equal('{"this":"is","my":"boomstick"}', t)
+ end
+end
View
@@ -0,0 +1,4 @@
+$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "test")))
+require 'test/unit'
+require 'tc_unchunked'
+require 'tc_chunked'

0 comments on commit e1479e2

Please sign in to comment.