From 921f6945f24e5c4f47b43639e274df089120168b Mon Sep 17 00:00:00 2001 From: Julian Cheal Date: Tue, 21 Nov 2017 19:22:11 +0000 Subject: [PATCH] Added spec test to check msg is truncated to 1.megabyte --- spec/util/vmdb-logger_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/util/vmdb-logger_spec.rb b/spec/util/vmdb-logger_spec.rb index 34ccdae22..3dbc3c609 100644 --- a/spec/util/vmdb-logger_spec.rb +++ b/spec/util/vmdb-logger_spec.rb @@ -96,8 +96,14 @@ end context "long messages" do + before(:each) do + @logger = VMDBLogger.new(@log) + end + it "truncates long messages when max_message_size is set" do - # TODO Add test body! + msg = "a" * 1_572_864 # 1.5 mb in bytes + _, message = @logger.formatter.call(:error, Time.now.utc, "", msg).split("-- : ") + expect(message.strip.size).to eq(1.megabyte) end end