Skip to content

Commit

Permalink
Add gitea case to yaml downloader spec
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas authored and eduardoj committed Sep 27, 2022
1 parent bad86a3 commit 7ef4c03
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions src/api/spec/services/workflows/yaml_downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
RSpec.describe Workflows::YAMLDownloader, type: :service do
let(:yaml_downloader) { described_class.new(payload, token: build(:workflow_token)) }
let(:max_size) { Workflows::YAMLDownloader::MAX_FILE_SIZE }
let(:github_payload) do
{
scm: 'github',
commit_sha: '5d175d7f4c58d06907bba188fe9a4c8b6bd723da',
pr_number: 1,
source_branch: 'test-pr',
target_branch: 'master',
action: 'synchronize',
source_repository_full_name: 'rubhanazeem/hello_world',
target_repository_full_name: 'rubhanazeem/hello_world',
event: 'pull_request',
api_endpoint: 'https://api.github.com'
}
end

describe '#call' do
before do
Expand All @@ -30,7 +16,20 @@
yaml_downloader.call
end

let(:payload) { github_payload }
let(:payload) do
{
scm: 'github',
commit_sha: '5d175d7f4c58d06907bba188fe9a4c8b6bd723da',
pr_number: 1,
source_branch: 'test-pr',
target_branch: 'master',
action: 'synchronize',
source_repository_full_name: 'rubhanazeem/hello_world',
target_repository_full_name: 'rubhanazeem/hello_world',
event: 'pull_request',
api_endpoint: 'https://api.github.com'
}
end
let(:octokit_client) { instance_double(Octokit::Client) }
let(:url) { "https://raw.githubusercontent.com/#{payload[:target_repository_full_name]}/#{payload[:target_branch]}/.obs/workflows.yml" }

Expand All @@ -47,5 +46,23 @@

it { expect(Down).to have_received(:download).with(url, max_size: max_size) }
end

context 'gitea' do
let(:payload) do
{
scm: 'gitea',
target_branch: 'main',
target_repository_full_name: 'iggy/target_repo',
api_endpoint: 'https://gitea.opensuse.org'
}
end
let(:url) { "https://gitea.opensuse.org/#{payload[:target_repository_full_name]}/raw/branch/#{payload[:target_branch]}/.obs/workflows.yml" }

before do
yaml_downloader.call
end

it { expect(Down).to have_received(:download).with(url, max_size: max_size) }
end
end
end

0 comments on commit 7ef4c03

Please sign in to comment.