diff options
Diffstat (limited to 'spec/lib/gitlab/profiler_spec.rb')
-rw-r--r-- | spec/lib/gitlab/profiler_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/profiler_spec.rb b/spec/lib/gitlab/profiler_spec.rb index 5187c96b511..bfe1a588489 100644 --- a/spec/lib/gitlab/profiler_spec.rb +++ b/spec/lib/gitlab/profiler_spec.rb @@ -58,6 +58,30 @@ RSpec.describe Gitlab::Profiler do described_class.profile('/', user: user, private_token: private_token) end + + context 'with sampling profiler' do + it 'generates sampling data' do + user = double(:user) + temp_data = Tempfile.new + + expect(described_class).to receive(:with_user).with(user).and_call_original + described_class.profile('/', user: user, sampling_mode: true, profiler_options: { out: temp_data.path }) + + expect(File.stat(temp_data).size).to be > 0 + File.unlink(temp_data) + end + + it 'saves sampling data with a randomly-generated filename' do + user = double(:user) + + expect(described_class).to receive(:with_user).with(user).and_call_original + result = described_class.profile('/', user: user, sampling_mode: true) + + expect(result).to be_a(File) + expect(File.stat(result.path).size).to be > 0 + File.unlink(result.path) + end + end end describe '.create_custom_logger' do |