Skip to content

Commit

Permalink
test: added tests for prefixed indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
keithgg committed Jan 12, 2023
1 parent 6f70cfa commit e2396e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/lib/task_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,27 @@ def assert_alias_points_to_index(alias_name, index_name)

end

context("#validate_prefixes") do
subject { TaskHelpers::ElasticsearchHelper}
PREFIX = 'prefix_'

before(:each) do
CommentService.config[:elasticsearch_index_prefix] = PREFIX
end

after(:each) do
CommentService.config[:elasticsearch_index_prefix] = ""
end

it "fails if indexes aren't prefixed" do
expect(TaskHelpers::ElasticsearchHelper.prefixed_index_names).to eq(["prefix_comments", "prefix_comment_threads"])
end

it "fails if indexes created indexes aren't prefixed" do
CommentService.config[:elasticsearch_index_prefix] = PREFIX
expect(TaskHelpers::ElasticsearchHelper.create_indices.all? {|v| v.start_with?(PREFIX)} ).to be_truthy
end
end

end
end

0 comments on commit e2396e6

Please sign in to comment.