Add configurable limits for number of builds allowed under a namespace
We also support that limit being increased automatically once a successful billing charge has gone through
This commit is contained in:
parent
62971b7f20
commit
9a452ace11
10 changed files with 125 additions and 33 deletions
31
endpoints/test/test_building.py
Normal file
31
endpoints/test/test_building.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
|
||||
from data import model
|
||||
from endpoints.building import start_build, PreparedBuild, MaximumBuildsQueuedException
|
||||
|
||||
from test.fixtures import *
|
||||
|
||||
def test_maximum_builds(app):
|
||||
# Change the maximum number of builds to 1.
|
||||
user = model.user.create_user('foobar', 'password', 'foo@example.com')
|
||||
user.maximum_queued_builds_count = 1
|
||||
user.save()
|
||||
|
||||
repo = model.repository.create_repository('foobar', 'somerepo', user)
|
||||
|
||||
# Try to queue a build; should succeed.
|
||||
prepared_build = PreparedBuild()
|
||||
prepared_build.build_name = 'foo'
|
||||
prepared_build.is_manual = True
|
||||
prepared_build.dockerfile_id = 'foobar'
|
||||
prepared_build.archive_url = 'someurl'
|
||||
prepared_build.tags = ['latest']
|
||||
prepared_build.subdirectory = '/'
|
||||
prepared_build.context = '/'
|
||||
prepared_build.metadata = {}
|
||||
|
||||
start_build(repo, prepared_build)
|
||||
|
||||
# Try to queue a second build; should fail.
|
||||
with pytest.raises(MaximumBuildsQueuedException):
|
||||
start_build(repo, prepared_build)
|
Reference in a new issue