Skip to content

Commit

Permalink
Compatibility updates and spec fixes (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzunk authored Feb 18, 2023
1 parent a27fcb5 commit 9f358c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/redis/time_series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def parse_madd_values(key, raw)
end
else
# single value, no timestamp
[key, '*', raw]
[[key, '*', raw]]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redis/time_series/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def cmd(name, *args)
end

def cmd_with_redis(redis, name, *args)
args = args.flatten.compact.map { |arg| arg.is_a?(Time) ? arg.ts_msec : arg }
args = args.flatten.compact.map { |arg| arg.is_a?(Time) ? arg.ts_msec : arg.to_s }
puts "DEBUG: #{name} #{args.join(' ')}" if debug
redis.call name, args
end
Expand Down
13 changes: 9 additions & 4 deletions spec/redis/time_series_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,15 @@ def msec(ts)
let(:time) { Time.now }
let(:ts_msec) { time.to_i * 1000 }

before { travel_to time }
after { travel_back }
before do
%i[foo bar baz].each { |key| described_class.create(key) }
travel_to time
end

after do
%i[foo bar baz].each { |key| described_class.destroy(key) }
travel_back
end

specify do
expect { described_class.madd(foo: 1, bar: 2, baz: 3) }.to issue_command \
Expand All @@ -190,11 +197,9 @@ def msec(ts)
end

it 'correctly returns samples' do
described_class.create(:foo)
expect(described_class.madd(foo: { 123 => 1, 456 => 2 })).to all(
be_a(Redis::TimeSeries::Sample)
)
described_class.destroy(:foo)
end
end
end
Expand Down

0 comments on commit 9f358c9

Please sign in to comment.