From a51d2e7c9a8034b5c56dcf0857f299ca77fc8c45 Mon Sep 17 00:00:00 2001 From: Geoff Wilson Date: Thu, 24 Oct 2024 12:57:22 -0400 Subject: [PATCH] Fix test --- ...t_log_formatter_test.rb => json_log_formatter_test.rb} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename test/lib/{audit_log_formatter_test.rb => json_log_formatter_test.rb} (70%) diff --git a/test/lib/audit_log_formatter_test.rb b/test/lib/json_log_formatter_test.rb similarity index 70% rename from test/lib/audit_log_formatter_test.rb rename to test/lib/json_log_formatter_test.rb index e23e185..ad73b6e 100644 --- a/test/lib/audit_log_formatter_test.rb +++ b/test/lib/json_log_formatter_test.rb @@ -1,19 +1,19 @@ require "test_helper" -class AuditLogFormatterTest < ActiveSupport::TestCase +class JsonLogFormatterTest < ActiveSupport::TestCase setup do Thread.current[:request_id] = nil end test "#call formats logformatter inputs as json" do t = Time.now - result = AuditLogFormatter.new.call("info", t, nil, "some message") + result = JsonLogFormatter.new.call("info", t, nil, "some message") assert_equal %Q({"type":"info","time":"#{t}","request_id":null,"message":"some message"}\n), result end test "#call accepts and merges a Hash type for the message" do t = Time.now - result = AuditLogFormatter.new.call("info", t, nil, { key: "some message", key2: "another" }) + result = JsonLogFormatter.new.call("info", t, nil, { key: "some message", key2: "another" }) assert_equal %Q({"type":"info","time":"#{t}","request_id":null,"key":"some message","key2":"another"}\n), result end @@ -21,7 +21,7 @@ class AuditLogFormatterTest < ActiveSupport::TestCase t = Time.now req_id = SecureRandom.hex Thread.stub :current, { request_id: req_id } do - result = AuditLogFormatter.new.call("info", t, nil, { key: "some message" }) + result = JsonLogFormatter.new.call("info", t, nil, { key: "some message" }) assert_equal %Q({"type":"info","time":"#{t}","request_id":"#{req_id}","key":"some message"}\n), result end end