Skip to content

Commit

Permalink
Fixed tests and time serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Beder committed Mar 6, 2017
1 parent 9504b7b commit 517828b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/health_monitor/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def check(request: nil)
{
results: results,
status: results.all? { |res| res[:status] == STATUSES[:ok] } ? :ok : :service_unavailable,
timestamp: Time.now
timestamp: Time.now.to_s(:rfc2822)
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/health_monitor/providers/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RedisException < StandardError; end

class Redis < Base
def check!
time = Time.now.to_s(:db)
time = Time.now.to_s(:rfc2822)

redis = ::Redis.new
redis.set(key, time)
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/health_monitor/health_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
'status' => 'ok',
'timestamp' => '1990-01-01T00:00:00.000+01:00'
'timestamp' => time.to_s(:rfc2822)
)
end
end
Expand Down Expand Up @@ -95,7 +95,7 @@
}
],
'status' => 'ok',
'timestamp' => '1990-01-01T00:00:00.000+01:00',
'timestamp' => time.to_s(:rfc2822),
'environment_variables' => {
'build_number' => '12',
'git_sha' => 'example_sha'
Expand Down Expand Up @@ -128,7 +128,7 @@
}
],
'status' => 'ok',
'timestamp' => '1990-01-01T00:00:00.000+01:00'
'timestamp' => time.to_s(:rfc2822)
)
end

Expand All @@ -152,7 +152,7 @@
}
],
'status' => 'service_unavailable',
'timestamp' => '1990-01-01T00:00:00.000+01:00'
'timestamp' => time.to_s(:rfc2822)
)
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/health_monitor/monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
}
],
:status => :ok,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)
end
end
Expand Down Expand Up @@ -111,7 +111,7 @@
}
],
:status => :ok,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)
end

Expand All @@ -130,12 +130,12 @@
},
{
name: 'Redis',
message: "different values (now: #{time.to_s(:db)}, fetched: false)",
message: "different values (now: #{time}, fetched: false)",
status: 'ERROR'
}
],
:status => :service_unavailable,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)
end
end
Expand All @@ -160,7 +160,7 @@
}
],
:status => :ok,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)
end
end
Expand All @@ -181,12 +181,12 @@
},
{
name: 'Redis',
message: "different values (now: #{time.to_s(:db)}, fetched: false)",
message: "different values (now: #{time}, fetched: false)",
status: 'ERROR'
}
],
:status => :service_unavailable,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)
end
end
Expand Down Expand Up @@ -224,7 +224,7 @@
}
],
:status => :service_unavailable,
:timestamp => time
:timestamp => time.to_s(:rfc2822)
)

expect(test).to be_truthy
Expand Down

0 comments on commit 517828b

Please sign in to comment.