Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bind_index_manager_spec.rb « click_house « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c659017c636f48a4a634fb89076d3cd1fb69cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ClickHouse::BindIndexManager, feature_category: :database do
  describe '#next_bind_str' do
    context 'when initialized without a start index' do
      let(:bind_manager) { described_class.new }

      it 'starts from index 1 by default' do
        expect(bind_manager.next_bind_str).to eq('$1')
      end

      it 'increments the bind string on subsequent calls' do
        bind_manager.next_bind_str
        expect(bind_manager.next_bind_str).to eq('$2')
      end
    end

    context 'when initialized with a start index' do
      let(:bind_manager) { described_class.new(2) }

      it 'starts from the given index' do
        expect(bind_manager.next_bind_str).to eq('$2')
      end

      it 'increments the bind string on subsequent calls' do
        bind_manager.next_bind_str
        expect(bind_manager.next_bind_str).to eq('$3')
      end
    end
  end
end