Fix tests related to sync object timestamps

pull/1540/head
Rick Carlino 2019-10-24 14:32:27 -05:00
parent bf418ead32
commit d825ec5540
2 changed files with 6 additions and 4 deletions

View File

@ -2,7 +2,6 @@ module Devices
class Sync < Mutations::Command
SEL = "SELECT id, updated_at FROM"
WHERE = "WHERE device_id = "
# "2019-08-14 18:33:08.428306"
FORMAT = "%Y-%m-%d %H:%M:%S.%5N"
def self.basic_query(plural_resource, where = WHERE)
@ -38,7 +37,6 @@ module Devices
real_stuff = QUERIES.reduce({}) do |acc, (key, value)|
acc.update(key => conn.execute(value + device.id.to_s).values)
end
binding.pry
real_stuff.merge({ first_party_farmwares: STUB_FARMWARES })
end
end

View File

@ -36,7 +36,8 @@ describe Api::DevicesController do
pair = json[:devices].first
expect(pair.first).to eq(device.id)
real_time = device.updated_at.strftime(FORMAT).sub(/0+$/, "")
expect(pair.last).to include(real_time)
diff = (device.updated_at - DateTime.parse(pair.last))
expect(diff).to be < 1
expect(pair.last.first(8)).to eq(device.updated_at.as_json.first(8))
json.keys.without(*EDGE_CASES).map do |key|
array = json[key]
@ -56,7 +57,10 @@ describe Api::DevicesController do
json[key].each_with_index do |item, index|
comparison = expected[index]
expect(item.first).to eq(comparison.first)
expect(Time.parse(item.last)).to eq(comparison.last.to_time)
left = Time.parse(item.last)
right = comparison.last.to_time.utc
expect((right - left).seconds).to be < 1
expect((right - left).seconds).to be >= 0
end
end
end