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

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

require 'spec_helper'

RSpec.describe Gitlab::Harbor::Client do
  let(:harbor_integration) { build(:harbor_integration) }

  subject(:client) { described_class.new(harbor_integration) }

  describe '#ping' do
    let!(:harbor_ping_request) { stub_harbor_request("https://demo.goharbor.io/api/v2.0/ping") }

    it "calls api/v2.0/ping successfully" do
      expect(client.ping).to eq(success: true)
    end
  end

  private

  def stub_harbor_request(url, body: {}, status: 200, headers: {})
    stub_request(:get, url)
      .to_return(
        status: status,
        headers: { 'Content-Type' => 'application/json' }.merge(headers),
        body: body.to_json
      )
  end
end