diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-05 09:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-05 09:09:26 +0300 |
commit | 5092e9b37cf208ec604470afd4ebb62b1b58673e (patch) | |
tree | 63791ca37fcf888cadfcd24ce2708d745d5fcf44 /spec/graphql | |
parent | 4b4d338d32fa30c7dcbf0ed54e99c00a56d66ff3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/resolvers/project_pipeline_resolver_spec.rb | 37 | ||||
-rw-r--r-- | spec/graphql/types/ci/pipeline_type_spec.rb | 2 |
2 files changed, 34 insertions, 5 deletions
diff --git a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb index b852b349d4f..69127c4b061 100644 --- a/spec/graphql/resolvers/project_pipeline_resolver_spec.rb +++ b/spec/graphql/resolvers/project_pipeline_resolver_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Resolvers::ProjectPipelineResolver do include GraphqlHelpers let_it_be(:project) { create(:project) } - let_it_be(:pipeline) { create(:ci_pipeline, project: project, iid: '1234') } + let_it_be(:pipeline) { create(:ci_pipeline, project: project, iid: '1234', sha: 'sha') } let_it_be(:other_pipeline) { create(:ci_pipeline) } let(:current_user) { create(:user) } @@ -30,7 +30,15 @@ RSpec.describe Resolvers::ProjectPipelineResolver do expect(result).to eq(pipeline) end - it 'keeps the queries under the threshold' do + it 'resolves pipeline for the passed sha' do + result = batch_sync do + resolve_pipeline(project, { sha: 'sha' }) + end + + expect(result).to eq(pipeline) + end + + it 'keeps the queries under the threshold for iid' do create(:ci_pipeline, project: project, iid: '1235') control = ActiveRecord::QueryRecorder.new do @@ -45,6 +53,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do end.not_to exceed_query_limit(control) end + it 'keeps the queries under the threshold for sha' do + create(:ci_pipeline, project: project, sha: 'sha2') + + control = ActiveRecord::QueryRecorder.new do + batch_sync { resolve_pipeline(project, { sha: 'sha' }) } + end + + expect do + batch_sync do + resolve_pipeline(project, { sha: 'sha' }) + resolve_pipeline(project, { sha: 'sha2' }) + end + end.not_to exceed_query_limit(control) + end + it 'does not resolve a pipeline outside the project' do result = batch_sync do resolve_pipeline(other_pipeline.project, { iid: '1234' }) @@ -53,8 +76,14 @@ RSpec.describe Resolvers::ProjectPipelineResolver do expect(result).to be_nil end - it 'errors when no iid is passed' do - expect { resolve_pipeline(project, {}) }.to raise_error(ArgumentError) + it 'errors when no iid or sha is passed' do + expect { resolve_pipeline(project, {}) } + .to raise_error(Gitlab::Graphql::Errors::ArgumentError) + end + + it 'errors when both iid and sha are passed' do + expect { resolve_pipeline(project, { iid: '1234', sha: 'sha' }) } + .to raise_error(Gitlab::Graphql::Errors::ArgumentError) end context 'when the pipeline is a dangling pipeline' do diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb index c4b34ca5316..e0e84a1b635 100644 --- a/spec/graphql/types/ci/pipeline_type_spec.rb +++ b/spec/graphql/types/ci/pipeline_type_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Types::Ci::PipelineType do id iid sha before_sha status detailed_status config_source duration coverage created_at updated_at started_at finished_at committed_at stages user retryable cancelable jobs source_job downstream - upstream path project active user_permissions warnings + upstream path project active user_permissions warnings commit_path ] if Gitlab.ee? |