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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/grape_logging/loggers/urgency_logger_spec.rb')
-rw-r--r--spec/lib/gitlab/grape_logging/loggers/urgency_logger_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/lib/gitlab/grape_logging/loggers/urgency_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/urgency_logger_spec.rb
new file mode 100644
index 00000000000..464534f0271
--- /dev/null
+++ b/spec/lib/gitlab/grape_logging/loggers/urgency_logger_spec.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GrapeLogging::Loggers::UrgencyLogger do
+ def endpoint(options, namespace: '')
+ Struct.new(:options, :namespace).new(options, namespace)
+ end
+
+ let(:api_class) do
+ Class.new(API::Base) do
+ namespace 'testing' do
+ # rubocop:disable Rails/HttpPositionalArguments
+ # This is not the get that performs a request, but the one from Grape
+ get 'test', urgency: :high do
+ {}
+ end
+ # rubocop:enable Rails/HttpPositionalArguments
+ end
+ end
+ end
+
+ describe ".parameters" do
+ where(:request_env, :expected_parameters) do
+ [
+ [{}, {}],
+ [{ 'api.endpoint' => endpoint({}) }, {}],
+ [{ 'api.endpoint' => endpoint({ for: 'something weird' }) }, {}],
+ [
+ { 'api.endpoint' => endpoint({ for: api_class, path: [] }) },
+ { request_urgency: :default, target_duration_s: 1 }
+ ],
+ [
+ { 'api.endpoint' => endpoint({ for: api_class, path: ['test'] }, namespace: '/testing') },
+ { request_urgency: :high, target_duration_s: 0.25 }
+ ]
+ ]
+ end
+
+ with_them do
+ let(:request) { double('request', env: request_env) }
+
+ subject { described_class.new.parameters(request, nil) }
+
+ it { is_expected.to eq(expected_parameters) }
+ end
+ end
+end