Skip to content

Commit

Permalink
[fix] untangle logfile names for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
criess committed Sep 2, 2021
1 parent 61ee867 commit bb90e2c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/instrumentors/logging_instrumentor_tests.rb
@@ -1,12 +1,13 @@
require 'logger'
require 'tempfile'

Shindo.tests('logging instrumentor') do
env_init

tests("connection logger").returns(true) do
Excon.stub({:method => :get}, {body: 'body', status: 200})

log_path = "/tmp/excon_#{Time.now.to_i}.txt"
log_path = Tempfile.create.path
logger = Logger.new(log_path)
# omit datetime to simplify test matcher
logger.formatter = proc do |severity, datetime, progname, msg|
Expand All @@ -19,8 +20,10 @@
logger: logger,
mock: true
)

response = connection.request(method: :get, path: '/logger')
File.readlines(log_path)[1..2] == [

File.readlines(log_path) == [
"request: http://127.0.0.1/logger\n",
"response: body\n"
]
Expand All @@ -29,7 +32,7 @@
tests("connection logger with query as hash").returns(true) do
Excon.stub({:method => :get}, {body: 'body', status: 200})

log_path = "/tmp/excon_#{Time.now.to_i}.txt"
log_path = Tempfile.create.path
logger = Logger.new(log_path)
# omit datetime to simplify test matcher
logger.formatter = proc do |severity, datetime, progname, msg|
Expand All @@ -47,7 +50,7 @@
path: '/logger',
query: {test: 'test'}
)
File.readlines(log_path)[1..2] == [
File.readlines(log_path) == [
"request: http://127.0.0.1/logger?test=test\n",
"response: body\n"
]
Expand Down

0 comments on commit bb90e2c

Please sign in to comment.