diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 21:08:00 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 21:08:00 +0000 |
commit | 69d6d3ca2013e97cfd2d89449669ea7bf475f4e9 (patch) | |
tree | 2cc4227ebfc52b7603691f06b0b8e09e030e8428 /spec/services/metrics/sample_metrics_service_spec.rb | |
parent | 01fdcf49b1553c22ae116fe96cedd7b91d02225c (diff) | |
download | gitlab-ce-69d6d3ca2013e97cfd2d89449669ea7bf475f4e9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/metrics/sample_metrics_service_spec.rb')
-rw-r--r-- | spec/services/metrics/sample_metrics_service_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/services/metrics/sample_metrics_service_spec.rb b/spec/services/metrics/sample_metrics_service_spec.rb new file mode 100644 index 00000000000..8574674ebc4 --- /dev/null +++ b/spec/services/metrics/sample_metrics_service_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Metrics::SampleMetricsService do + describe 'query' do + subject { described_class.new(identifier).query } + + context 'when the file is not found' do + let(:identifier) { nil } + + it { is_expected.to be_nil } + end + + context 'when the file is found' do + let(:identifier) { 'sample_metric_query_result' } + let(:source) { File.join(Rails.root, 'spec/fixtures/gitlab/sample_metrics', "#{identifier}.yml") } + let(:destination) { File.join(Rails.root, Metrics::SampleMetricsService::DIRECTORY, "#{identifier}.yml") } + + around do |example| + FileUtils.mkdir_p(Metrics::SampleMetricsService::DIRECTORY) + FileUtils.cp(source, destination) + + example.run + ensure + FileUtils.rm(destination) + end + + subject { described_class.new(identifier).query } + + it 'loads data from the sample file correctly' do + expect(subject).to eq(YAML.load_file(source)) + end + end + + context 'when the identifier is for a path outside of sample_metrics' do + let(:identifier) { '../config/secrets' } + + it { is_expected.to be_nil } + end + end +end |