-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete the Remote Mirrors endpoint
Signed-off-by: Balasankar 'Balu' C <[email protected]>
- Loading branch information
Balasankar 'Balu' C
committed
Oct 30, 2024
1 parent
bcfeb45
commit 5ff0448
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"enabled":true,"id":123456,"keep_divergent_refs":true,"last_error":"Some refs have diverged and have not been updated on the remote:\n\nrefs/heads/master","last_successful_update_at":"2020-08-11T15:36:04.668Z","last_update_at":"2020-08-11T15:37:20.701Z","last_update_started_at":"2020-08-11T15:37:17.659Z","only_protected_branches":true,"update_status":"failed","url":"https://*****:*****@gitlab.com/mirror/target.git"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,23 @@ | |
end | ||
end | ||
|
||
describe '.remote_mirror' do | ||
before do | ||
stub_get('/projects/5/remote_mirrors/123456', 'remote_mirror') | ||
@mirror = Gitlab.remote_mirror(5, 123_456) | ||
end | ||
|
||
it 'gets the correct resource' do | ||
expect(a_get('/projects/5/remote_mirrors/123456')).to have_been_made | ||
end | ||
|
||
it "returns a paginated response of project's push mirrors" do | ||
expect(@mirror).to be_a Gitlab::ObjectifiedHash | ||
expect(@mirror.enabled).to be(true) | ||
expect(@mirror.url).to include('gitlab.com/mirror/target.git') | ||
end | ||
end | ||
|
||
describe '.create_remote_mirror' do | ||
let(:api_path) { '/projects/5/remote_mirrors' } | ||
let(:mirror_path) { 'https://username:[email protected]/gitlab/example.git' } | ||
|
@@ -67,4 +84,34 @@ | |
expect(@mirror.keep_divergent_refs).to be(true) | ||
end | ||
end | ||
|
||
describe '.delete_remote_mirror' do | ||
before do | ||
stub_request(:delete, "#{Gitlab.endpoint}/projects/5/remote_mirrors/123456") | ||
.with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) | ||
.to_return(status: 204) | ||
@mirror = Gitlab.delete_remote_mirror(5, 123_456) | ||
end | ||
|
||
it 'deletes the correct resource' do | ||
expect(a_delete('/projects/5/remote_mirrors/123456')).to have_been_made | ||
end | ||
|
||
it 'removes the mirror' do | ||
expect(@mirror.to_h).to be_empty | ||
end | ||
end | ||
|
||
describe '.sync_remote_mirror' do | ||
before do | ||
stub_request(:post, "#{Gitlab.endpoint}/projects/5/remote_mirrors/123456/sync") | ||
.with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) | ||
.to_return(status: 204) | ||
@mirror = Gitlab.sync_remote_mirror(5, 123_456) | ||
end | ||
|
||
it 'executes a POST to the correct resource' do | ||
expect(a_post('/projects/5/remote_mirrors/123456/sync')).to have_been_made | ||
end | ||
end | ||
end |