diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-29 15:14:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-29 15:14:45 +0300 |
commit | 27f6da0ab2b8f1945a78709c7b5d540a6cc400fd (patch) | |
tree | 1a9d2e332984f457e359f4bed051596e96ee6088 /spec/requests | |
parent | a056c4d05f51985f2228dcb66d302279855e9b3c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/ci/jobs_spec.rb | 66 | ||||
-rw-r--r-- | spec/requests/api/namespaces_spec.rb | 22 |
2 files changed, 84 insertions, 4 deletions
diff --git a/spec/requests/api/ci/jobs_spec.rb b/spec/requests/api/ci/jobs_spec.rb index 59a9836e530..a1a0086d96b 100644 --- a/spec/requests/api/ci/jobs_spec.rb +++ b/spec/requests/api/ci/jobs_spec.rb @@ -308,6 +308,7 @@ RSpec.describe API::Ci::Jobs do it 'returns no artifacts nor trace data' do json_job = json_response.first + expect(response).to have_gitlab_http_status(:ok) expect(json_job['artifacts_file']).to be_nil expect(json_job['artifacts']).to be_an Array expect(json_job['artifacts']).to be_empty @@ -426,6 +427,22 @@ RSpec.describe API::Ci::Jobs do expect(response).to have_gitlab_http_status(:unauthorized) end end + + context 'when trace artifact record exists with no stored file', :skip_before_request do + before do + create(:ci_job_artifact, :unarchived_trace_artifact, job: job, project: job.project) + end + + it 'returns no artifacts nor trace data' do + get api("/projects/#{project.id}/jobs/#{job.id}", api_user) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['artifacts']).to be_an Array + expect(json_response['artifacts'].size).to eq(1) + expect(json_response['artifacts'][0]['file_type']).to eq('trace') + expect(json_response['artifacts'][0]['filename']).to eq('job.log') + end + end end describe 'DELETE /projects/:id/jobs/:job_id/artifacts' do @@ -1024,7 +1041,16 @@ RSpec.describe API::Ci::Jobs do end end - context 'when trace is file' do + context 'when live trace and uploadless trace artifact' do + let(:job) { create(:ci_build, :trace_live, :unarchived_trace_artifact, pipeline: pipeline) } + + it 'returns specific job trace' do + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to eq(job.trace.raw) + end + end + + context 'when trace is live' do let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) } it 'returns specific job trace' do @@ -1032,6 +1058,28 @@ RSpec.describe API::Ci::Jobs do expect(response.body).to eq(job.trace.raw) end end + + context 'when no trace' do + let(:job) { create(:ci_build, pipeline: pipeline) } + + it 'returns empty trace' do + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to be_empty + end + end + + context 'when trace artifact record exists with no stored file' do + let(:job) { create(:ci_build, pipeline: pipeline) } + + before do + create(:ci_job_artifact, :unarchived_trace_artifact, job: job, project: job.project) + end + + it 'returns empty trace' do + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to be_empty + end + end end context 'unauthorized user' do @@ -1143,9 +1191,7 @@ RSpec.describe API::Ci::Jobs do post api("/projects/#{project.id}/jobs/#{job.id}/erase", user) end - context 'job is erasable' do - let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) } - + shared_examples_for 'erases job' do it 'erases job content' do expect(response).to have_gitlab_http_status(:created) expect(job.job_artifacts.count).to eq(0) @@ -1154,6 +1200,12 @@ RSpec.describe API::Ci::Jobs do expect(job.artifacts_metadata.present?).to be_falsy expect(job.has_job_artifacts?).to be_falsy end + end + + context 'job is erasable' do + let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) } + + it_behaves_like 'erases job' it 'updates job' do job.reload @@ -1163,6 +1215,12 @@ RSpec.describe API::Ci::Jobs do end end + context 'when job has an unarchived trace artifact' do + let(:job) { create(:ci_build, :success, :trace_live, :unarchived_trace_artifact, project: project, pipeline: pipeline) } + + it_behaves_like 'erases job' + end + context 'job is not erasable' do let(:job) { create(:ci_build, :trace_live, project: project, pipeline: pipeline) } diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 0a569819205..43bbc6f3ca8 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -272,6 +272,16 @@ RSpec.describe API::Namespaces do expect(response).to have_gitlab_http_status(:unauthorized) end + + context 'when requesting project_namespace' do + let(:namespace_id) { project_namespace.id } + + it 'returns authentication error' do + get api("/namespaces/#{project_namespace.path}/exists"), params: { parent_id: group2.id } + + expect(response).to have_gitlab_http_status(:unauthorized) + end + end end context 'when authenticated' do @@ -330,6 +340,18 @@ RSpec.describe API::Namespaces do expect(response).to have_gitlab_http_status(:ok) expect(response.body).to eq(expected_json) end + + context 'when requesting project_namespace' do + let(:namespace_id) { project_namespace.id } + + it 'returns JSON indicating the namespace does not exist without a suggestion' do + get api("/namespaces/#{project_namespace.path}/exists", user), params: { parent_id: group2.id } + + expected_json = { exists: false, suggests: [] }.to_json + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to eq(expected_json) + end + end end end end |