Commit d7d2b651 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Add tests for RegisterBuildService how builds are picked when they have a quota set

parent 1dbf1e6e
...@@ -130,6 +130,62 @@ module Ci ...@@ -130,6 +130,62 @@ module Ci
end end
end end
context 'for project with shared runners when global minutes limit is set' do
before do
project.update(shared_runners_enabled: true)
stub_application_setting(shared_runners_minutes: 500)
end
context 'allow to pick builds' do
let(:build) { execute(shared_runner) }
it { expect(build).to be_kind_of(Build) }
end
context 'when over the global quota' do
before do
project.namespace.create_namespace_metrics(
shared_runners_minutes: 600)
end
let(:build) { execute(shared_runner) }
it "does not return a build" do
expect(build).to be_nil
end
context 'when project is public' do
before do
project.update(visibility_level: Project::PUBLIC)
end
it "does return the build" do
expect(build).to be_kind_of(Build)
end
end
context 'when namespace limit is set to unlimited' do
before do
project.namespace.update(shared_runners_minutes_limit: 0)
end
it "does return the build" do
expect(build).to be_kind_of(Build)
end
end
context 'when namespace quota is bigger than a global one' do
before do
project.namespace.update(shared_runners_minutes_limit: 1000)
end
it "does return the build" do
expect(build).to be_kind_of(Build)
end
end
end
end
context 'disallow shared runners' do context 'disallow shared runners' do
before do before do
project.update(shared_runners_enabled: false) project.update(shared_runners_enabled: false)
......
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