BigW Consortium Gitlab

Commit ac872078 by Lin Jen-Shin

Test build API if expire_in not set, set to app default

parent 3e158bec
...@@ -630,6 +630,7 @@ describe Ci::API::Builds do ...@@ -630,6 +630,7 @@ describe Ci::API::Builds do
context 'with an expire date' do context 'with an expire date' do
let!(:artifacts) { file_upload } let!(:artifacts) { file_upload }
let(:default_artifacts_expiration) { 0 }
let(:post_data) do let(:post_data) do
{ 'file.path' => artifacts.path, { 'file.path' => artifacts.path,
...@@ -638,7 +639,8 @@ describe Ci::API::Builds do ...@@ -638,7 +639,8 @@ describe Ci::API::Builds do
end end
before do before do
stub_application_setting(default_artifacts_expiration: 0) stub_application_setting(
default_artifacts_expiration: default_artifacts_expiration)
post(post_url, post_data, headers_with_token) post(post_url, post_data, headers_with_token)
end end
...@@ -650,7 +652,8 @@ describe Ci::API::Builds do ...@@ -650,7 +652,8 @@ describe Ci::API::Builds do
build.reload build.reload
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['artifacts_expire_at']).not_to be_empty expect(json_response['artifacts_expire_at']).not_to be_empty
expect(build.artifacts_expire_at).to be_within(5.minutes).of(Time.now + 7.days) expect(build.artifacts_expire_at).
to be_within(5.minutes).of(7.days.from_now)
end end
end end
...@@ -663,6 +666,18 @@ describe Ci::API::Builds do ...@@ -663,6 +666,18 @@ describe Ci::API::Builds do
expect(json_response['artifacts_expire_at']).to be_nil expect(json_response['artifacts_expire_at']).to be_nil
expect(build.artifacts_expire_at).to be_nil expect(build.artifacts_expire_at).to be_nil
end end
context 'with application default' do
let(:default_artifacts_expiration) { 5 }
it 'sets to application default' do
build.reload
expect(response).to have_http_status(201)
expect(json_response['artifacts_expire_at']).not_to be_empty
expect(build.artifacts_expire_at).
to be_within(5.minutes).of(5.days.from_now)
end
end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment