Sha256: ebf7504ea6582e81a155dba7c7b6072fe5d21d224b4d75ee2f6e639c3bf5a586

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'


class RepositoryTest < TestCase
  def setup
    @repository = Repository.new
    @repository.repository_for_indexing(TEST_REPO_PATH)
    Repository.__elasticsearch__.create_index! force: true
  end

  def test_index_commits
    commit_count = @repository.index_commits
    assert { commit_count == RepoInfo::COMMIT_COUNT }
  end

  def test_index_commits_after_first_push
    commit_count = @repository.index_commits(
        from_rev: "0000000000000000000000000000000000000000",
        to_rev: @repository.repository_for_indexing.head.target.oid)

    assert { commit_count == RepoInfo::COMMIT_COUNT }
  end

  #TODO write better assertions
  def test_index_all_blobs_from_head
    blob_count = @repository.index_blobs
    Repository.__elasticsearch__.refresh_index!

    result = @repository.search('def project_name_regex')
    assert { result[:blobs][:total_count]  == 1 }
  end

  #TODO write better assertions
  def test_index_blobs_after_first_push
    commit_count = @repository.index_blobs(
        from_rev: "0000000000000000000000000000000000000000",
        to_rev: @repository.repository_for_indexing.head.target.oid)
    Repository.__elasticsearch__.refresh_index!

    result = @repository.search('def project_name_regex')
    assert { result[:blobs][:total_count]  == 1 }
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
gitlab-elasticsearch-git-0.0.9 test/lib/repository_test.rb
gitlab-elasticsearch-git-0.0.8 test/lib/repository_test.rb
gitlab-elasticsearch-git-0.0.7 test/lib/repository_test.rb
gitlab-elasticsearch-git-0.0.6 test/lib/repository_test.rb
elasticsearch-git-0.0.5 test/lib/repository_test.rb