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

get_snippet_repository_query_spec.rb « graphql « projects « bulk_imports « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1bd4106297d5f0785e2981a0effaefbce95c9505 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe BulkImports::Projects::Graphql::GetSnippetRepositoryQuery do
  let_it_be(:entity) { create(:bulk_import_entity) }
  let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
  let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }

  subject(:query) { described_class.new(context: context) }

  it 'has a valid query' do
    parsed_query = GraphQL::Query.new(
      GitlabSchema,
      query.to_s,
      variables: query.variables
    )
    result = GitlabSchema.static_validator.validate(parsed_query)

    expect(result[:errors]).to be_empty
  end

  it 'returns snippet httpUrlToRepo' do
    expect(subject.to_s).to include('httpUrlToRepo')
  end

  it 'returns snippet createdAt' do
    expect(subject.to_s).to include('createdAt')
  end

  it 'returns snippet title' do
    expect(subject.to_s).to include('title')
  end

  describe '.variables' do
    it 'queries project based on source_full_path and pagination' do
      expected = { full_path: entity.source_full_path, cursor: nil, per_page: 500 }

      expect(subject.variables).to eq(expected)
    end
  end

  describe '.data_path' do
    it '.data_path returns data path' do
      expected = %w[data project snippets nodes]

      expect(subject.data_path).to eq(expected)
    end
  end

  describe '.page_info_path' do
    it '.page_info_path returns pagination information path' do
      expected = %w[data project snippets page_info]

      expect(subject.page_info_path).to eq(expected)
    end
  end
end