diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-05 21:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-05 21:09:16 +0300 |
commit | 2b2299ea5f8717ad59a47c1c40d951409dfeb35b (patch) | |
tree | 806b797004e307caf431cea03a6d3c913c1aaf4c /spec/graphql | |
parent | c4acd4624d61ef923453561a698c905c0ffa7b57 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
3 files changed, 66 insertions, 9 deletions
diff --git a/spec/graphql/resolvers/ci/runner_job_count_resolver_spec.rb b/spec/graphql/resolvers/ci/runner_job_count_resolver_spec.rb new file mode 100644 index 00000000000..6336ea883f7 --- /dev/null +++ b/spec/graphql/resolvers/ci/runner_job_count_resolver_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::Ci::RunnerJobCountResolver, feature_category: :runner_fleet do + include GraphqlHelpers + + let_it_be(:project) { create(:project, :repository) } + let_it_be(:pipeline) { create(:ci_pipeline, project: project) } + let_it_be(:irrelevant_pipeline) { create(:ci_pipeline, project: project) } + + let_it_be(:runner) { create(:ci_runner, :project, projects: [project]) } + + let_it_be(:build_one) { create(:ci_build, :success, name: 'Build One', runner: runner, pipeline: pipeline) } + let_it_be(:build_two) { create(:ci_build, :success, name: 'Build Two', runner: runner, pipeline: pipeline) } + let_it_be(:build_three) { create(:ci_build, :failed, name: 'Build Three', runner: runner, pipeline: pipeline) } + let_it_be(:irrelevant_build) { create(:ci_build, name: 'Irrelevant Build', pipeline: irrelevant_pipeline) } + + describe '#resolve' do + subject(:job_count) { resolve_job_count(args) } + + let(:args) { {} } + + context 'with authorized user', :enable_admin_mode do + let(:current_user) { create(:user, :admin) } + + context 'with statuses argument filtering on successful builds' do + let(:args) { { statuses: [Types::Ci::JobStatusEnum.coerce_isolated_input('SUCCESS')] } } + + it { is_expected.to eq 2 } + end + + context 'with statuses argument filtering on failed builds' do + let(:args) { { statuses: [Types::Ci::JobStatusEnum.coerce_isolated_input('FAILED')] } } + + it { is_expected.to eq 1 } + end + + context 'without statuses argument' do + it { is_expected.to eq 3 } + end + end + + context 'with unauthorized user' do + let(:current_user) { nil } + + it { is_expected.to be_nil } + end + end + + private + + def resolve_job_count(args = {}, context = { current_user: current_user }) + resolve(described_class, obj: runner, args: args, ctx: context)&.value + end +end diff --git a/spec/graphql/resolvers/ci/runner_jobs_resolver_spec.rb b/spec/graphql/resolvers/ci/runner_jobs_resolver_spec.rb index 963a642fa4e..322bead0d3c 100644 --- a/spec/graphql/resolvers/ci/runner_jobs_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/runner_jobs_resolver_spec.rb @@ -9,17 +9,18 @@ RSpec.describe Resolvers::Ci::RunnerJobsResolver, feature_category: :runner_flee let_it_be(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:irrelevant_pipeline) { create(:ci_pipeline, project: project) } - let!(:build_one) { create(:ci_build, :success, name: 'Build One', runner: runner, pipeline: pipeline) } - let!(:build_two) { create(:ci_build, :success, name: 'Build Two', runner: runner, pipeline: pipeline) } - let!(:build_three) { create(:ci_build, :failed, name: 'Build Three', runner: runner, pipeline: pipeline) } - let!(:irrelevant_build) { create(:ci_build, name: 'Irrelevant Build', pipeline: irrelevant_pipeline) } + let_it_be(:runner) { create(:ci_runner, :project, projects: [project]) } - let(:args) { {} } - let(:runner) { create(:ci_runner, :project, projects: [project]) } - - subject { resolve_jobs(args) } + let_it_be(:build_one) { create(:ci_build, :success, name: 'Build One', runner: runner, pipeline: pipeline) } + let_it_be(:build_two) { create(:ci_build, :success, name: 'Build Two', runner: runner, pipeline: pipeline) } + let_it_be(:build_three) { create(:ci_build, :failed, name: 'Build Three', runner: runner, pipeline: pipeline) } + let_it_be(:irrelevant_build) { create(:ci_build, name: 'Irrelevant Build', pipeline: irrelevant_pipeline) } describe '#resolve' do + subject(:jobs) { resolve_jobs(args) } + + let(:args) { {} } + context 'with authorized user', :enable_admin_mode do let(:current_user) { create(:user, :admin) } diff --git a/spec/graphql/types/commit_signatures/verification_status_enum_spec.rb b/spec/graphql/types/commit_signatures/verification_status_enum_spec.rb index a0d99f5f0c1..7fc600745df 100644 --- a/spec/graphql/types/commit_signatures/verification_status_enum_spec.rb +++ b/spec/graphql/types/commit_signatures/verification_status_enum_spec.rb @@ -10,7 +10,7 @@ RSpec.describe GitlabSchema.types['VerificationStatus'] do .to match_array(%w[ UNVERIFIED UNVERIFIED_KEY VERIFIED SAME_USER_DIFFERENT_EMAIL OTHER_USER UNKNOWN_KEY - MULTIPLE_SIGNATURES REVOKED_KEY + MULTIPLE_SIGNATURES REVOKED_KEY VERIFIED_SYSTEM ]) end end |