Sha256: 8426d56cdd70da159af3fc1605cf8c3857f8984ee0b49df62ab050557c29afa3

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe TestRepository do
  before do
    remove_index(TestRepository.index_name)
  end

  it "creates an index" do
    expect(index_exist?(TestRepository.index_name)).to be_falsey

    TestRepository.__elasticsearch__.create_index!

    expect(index_exist?(TestRepository.index_name)).to be_truthy
  end

  it "indexes all blobs and searches" do
    repo = TestRepository.new
    repo.index_blobs

    TestRepository.__elasticsearch__.refresh_index!

    expect(repo.search('def', type: :blob)[:blobs][:total_count]).to eq(4)
  end

  it "indexes all commits and searches" do
    repo = TestRepository.new
    repo.index_commits

    TestRepository.__elasticsearch__.refresh_index!
    
    expect(repo.search('test', type: :commit)[:commits][:total_count]).to eq(2)
  end

  it "searches through all types" do
    repo = TestRepository.new
    repo.index_commits
    repo.index_blobs

    TestRepository.__elasticsearch__.refresh_index!
    
    expect(repo.search('test')[:commits][:total_count]).to eq(2)
    expect(repo.search('def')[:blobs][:total_count]).to eq(4)
  end

  it "it indexes specified commits" do
    repo = TestRepository.new
    repo.index_commits(
      from_rev: '40f4a7a617393735a95a0bb67b08385bc1e7c66d',
      to_rev: '732401c65e924df81435deb12891ef570167d2e2'
    )

    TestRepository.__elasticsearch__.refresh_index!
    
    expect(repo.search('empty', type: :commit)[:commits][:total_count]).to eq(1)
  end

  it "it indexes specified blobs" do
    repo = TestRepository.new
    repo.index_blobs(
      from_rev: '40f4a7a617393735a95a0bb67b08385bc1e7c66d',
      to_rev: '732401c65e924df81435deb12891ef570167d2e2'
    )

    TestRepository.__elasticsearch__.refresh_index!
    
    expect(repo.search('Permission is hereby granted', type: :blob)[:blobs][:total_count]).to eq(1)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab-elasticsearch-git-0.0.13 spec/main_spec.rb
gitlab-elasticsearch-git-0.0.12 spec/main_spec.rb
gitlab-elasticsearch-git-0.0.11 spec/main_spec.rb
gitlab-elasticsearch-git-0.0.10 spec/main_spec.rb