debian-mirror-gitlab/spec/lib/gitlab/prometheus/query_variables_spec.rb

54 lines
1.6 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Prometheus::QueryVariables do
describe '.call' do
2019-07-31 22:56:46 +05:30
let(:project) { environment.project }
2019-02-15 15:39:39 +05:30
let(:environment) { create(:environment) }
let(:slug) { environment.slug }
subject { described_class.call(environment) }
it { is_expected.to include(ci_environment_slug: slug) }
it do
is_expected.to include(environment_filter:
%{container_name!="POD",environment="#{slug}"})
end
context 'without deployment platform' do
it { is_expected.to include(kube_namespace: '') }
end
context 'with deployment platform' do
2019-07-31 22:56:46 +05:30
context 'with project cluster' do
2019-10-12 21:52:04 +05:30
let(:kube_namespace) { environment.deployment_namespace }
2019-02-15 15:39:39 +05:30
2019-07-31 22:56:46 +05:30
before do
create(:cluster, :project, :provided_by_user, projects: [project])
end
it { is_expected.to include(kube_namespace: kube_namespace) }
2019-02-15 15:39:39 +05:30
end
2019-07-31 22:56:46 +05:30
context 'with group cluster' do
let(:cluster) { create(:cluster, :group, :provided_by_user, groups: [group]) }
let(:group) { create(:group) }
let(:project2) { create(:project) }
let(:kube_namespace) { k8s_ns.namespace }
2019-10-12 21:52:04 +05:30
let!(:k8s_ns) { create(:cluster_kubernetes_namespace, cluster: cluster, project: project, environment: environment) }
let!(:k8s_ns2) { create(:cluster_kubernetes_namespace, cluster: cluster, project: project2, environment: environment) }
2019-07-31 22:56:46 +05:30
before do
group.projects << project
group.projects << project2
end
it { is_expected.to include(kube_namespace: kube_namespace) }
end
2019-02-15 15:39:39 +05:30
end
end
end