Commit 9584a714 authored by Andreas Brandl's avatar Andreas Brandl

Add specs for additional tag

parent b1c50a0a
......@@ -74,32 +74,66 @@ RSpec.describe Gitlab::Database::Reindexing::GrafanaNotifier do
end
describe '#notify_start' do
subject { described_class.new(api_key, api_url, additional_tag).notify_start(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', additional_tag, action.index.tablename, action.index.name],
text: "Started reindexing of #{action.index.name} on #{action.index.tablename}"
}
context 'additional tag is nil' do
subject { described_class.new(api_key, api_url, nil).notify_start(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', action.index.tablename, action.index.name],
text: "Started reindexing of #{action.index.name} on #{action.index.tablename}"
}
end
it_behaves_like 'interacting with Grafana annotations API'
end
it_behaves_like 'interacting with Grafana annotations API'
context 'additional tag is not nil' do
subject { described_class.new(api_key, api_url, additional_tag).notify_start(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', additional_tag, action.index.tablename, action.index.name],
text: "Started reindexing of #{action.index.name} on #{action.index.tablename}"
}
end
it_behaves_like 'interacting with Grafana annotations API'
end
end
describe '#notify_end' do
subject { described_class.new(api_key, api_url, additional_tag).notify_end(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', additional_tag, action.index.tablename, action.index.name],
text: "Finished reindexing of #{action.index.name} on #{action.index.tablename} (#{action.state})",
timeEnd: (action.action_end.utc.to_f * 1000).to_i,
isRegion: true
}
context 'additional tag is nil' do
subject { described_class.new(api_key, api_url, nil).notify_end(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', action.index.tablename, action.index.name],
text: "Finished reindexing of #{action.index.name} on #{action.index.tablename} (#{action.state})",
timeEnd: (action.action_end.utc.to_f * 1000).to_i,
isRegion: true
}
end
it_behaves_like 'interacting with Grafana annotations API'
end
it_behaves_like 'interacting with Grafana annotations API'
context 'additional tag is not nil' do
subject { described_class.new(api_key, api_url, additional_tag).notify_end(action) }
let(:payload) do
{
time: (action.action_start.utc.to_f * 1000).to_i,
tags: ['reindex', additional_tag, action.index.tablename, action.index.name],
text: "Finished reindexing of #{action.index.name} on #{action.index.tablename} (#{action.state})",
timeEnd: (action.action_end.utc.to_f * 1000).to_i,
isRegion: true
}
end
it_behaves_like 'interacting with Grafana annotations API'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment