Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_pipeline_counts_resolver_spec.rb « ci « resolvers « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e04bed0f0773c63c2f8315a827499a415fdd8380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Resolvers::Ci::ProjectPipelineCountsResolver, feature_category: :continuous_integration do
  include GraphqlHelpers

  let(:current_user) { create(:user) }

  let_it_be(:project) { create(:project, :private) }
  let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
  let_it_be(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
  let_it_be(:success_pipeline) { create(:ci_pipeline, :success, project: project) }
  let_it_be(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
  let_it_be(:sha_pipeline) { create(:ci_pipeline, :running, project: project, sha: 'deadbeef') }
  let_it_be(:on_demand_dast_scan) { create(:ci_pipeline, :success, project: project, source: 'ondemand_dast_scan') }

  before do
    project.add_developer(current_user)
  end

  describe '#resolve' do
    it 'counts pipelines' do
      expect(resolve_pipeline_counts).to have_attributes(
        all: 6,
        finished: 3,
        running: 1,
        pending: 2
      )
    end

    it 'counts by ref' do
      expect(resolve_pipeline_counts(ref: "awesome-feature")).to have_attributes(
        all: 1,
        finished: 0,
        running: 0,
        pending: 1
      )
    end

    it 'counts by sha' do
      expect(resolve_pipeline_counts(sha: "deadbeef")).to have_attributes(
        all: 1,
        finished: 0,
        running: 1,
        pending: 0
      )
    end

    it 'counts by source' do
      expect(resolve_pipeline_counts(source: "ondemand_dast_scan")).to have_attributes(
        all: 1,
        finished: 1,
        running: 0,
        pending: 0
      )
    end
  end

  def resolve_pipeline_counts(args = {}, context = { current_user: current_user })
    resolve(described_class, obj: project, args: args, ctx: context)
  end
end