Sha256: 300852a6331b19a36ba6811649748201844057c0ac99cdd728a444ca888f8c1f

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'
require 'rhcf/timeseries/manager'


describe "Query" do
  describe "#better_resolution" do

    let(:redis){nil}
    describe "When having a smaller then 1/5 " do
      let(:series) { Rhcf::Timeseries::Manager.new(connection: redis, resolutions: [:hour, :"15minutes", :minute]) }
      it { expect(series.find('bla', Time.now - 3600, Time.now).better_resolution[:id]).to eq :minute }
    end

    describe "When having a smaller but greather then 1/5" do
      let(:series) { Rhcf::Timeseries::Manager.new(connection: redis,  resolutions: [:hour, :"15minutes"]) }
      it { expect(series.find('bla', Time.now - 3600, Time.now).better_resolution[:id]).to eq :"15minutes" }
    end

    describe "When having no smaller, only its size" do
      let(:series) { Rhcf::Timeseries::Manager.new(connection: redis,  resolutions: [:hour]) }
      it { expect(series.find('bla', DateTime.parse('2015-01-01 01:50:00'), DateTime.parse('2015-01-01 03:10:00')).better_resolution[:id]).to eq :hour }
    end

    describe "When having only bigger" do
      let(:series) { Rhcf::Timeseries::Manager.new(connection: redis,  resolutions: [:month]) }
      it { expect(series.find('bla', DateTime.parse('2015-01-01 01:50:00'), DateTime.parse('2015-01-01 03:10:00')).better_resolution).to be_nil}
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rhcf-timeseries-2.0.1pre spec/lib/rhcf/timeseries/query_spec.rb
rhcf-timeseries-2.0.0pre spec/lib/rhcf/timeseries/query_spec.rb
rhcf-timeseries-1.0.3 spec/lib/rhcf/timeseries/query_spec.rb
rhcf-timeseries-1.0.2 spec/lib/rhcf/timeseries/query_spec.rb
rhcf-timeseries-1.0.1 spec/lib/rhcf/timeseries/query_spec.rb
rhcf-timeseries-1.0.0 spec/lib/rhcf/timeseries/query_spec.rb