Fix the tests and the one bug that it highlighted.
This commit is contained in:
parent
b619356907
commit
e7064f1191
6 changed files with 53 additions and 24 deletions
|
@ -13,7 +13,7 @@ from util.names import format_robot_username
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
store = app.config['STORAGE']
|
||||
|
||||
transaction_factory = app.config['DB_TRANSACTION_FACTORY']
|
||||
|
||||
class DataModelException(Exception):
|
||||
pass
|
||||
|
@ -580,6 +580,9 @@ def _visible_repository_query(username=None, include_public=True, limit=None,
|
|||
|
||||
def _filter_to_repos_for_user(query, username=None, namespace=None,
|
||||
include_public=True):
|
||||
if not include_public and not username:
|
||||
return Repository.select().where(Repository.id == '-1')
|
||||
|
||||
where_clause = None
|
||||
if username:
|
||||
UserThroughTeam = User.alias()
|
||||
|
@ -872,7 +875,7 @@ def create_repository(namespace, name, creating_user, visibility='private'):
|
|||
|
||||
|
||||
def create_or_link_image(docker_image_id, repository, username, create=True):
|
||||
with db.transaction():
|
||||
with transaction_factory(db):
|
||||
query = (ImageStorage
|
||||
.select()
|
||||
.distinct()
|
||||
|
@ -934,7 +937,7 @@ def set_image_size(docker_image_id, namespace_name, repository_name,
|
|||
|
||||
def set_image_metadata(docker_image_id, namespace_name, repository_name,
|
||||
created_date_str, comment, command, parent=None):
|
||||
with db.transaction():
|
||||
with transaction_factory(db):
|
||||
query = (Image
|
||||
.select(Image, ImageStorage)
|
||||
.join(Repository)
|
||||
|
@ -980,7 +983,7 @@ def list_repository_tags(namespace_name, repository_name):
|
|||
|
||||
|
||||
def garbage_collect_repository(namespace_name, repository_name):
|
||||
with db.transaction():
|
||||
with transaction_factory(db):
|
||||
# Get a list of all images used by tags in the repository
|
||||
tag_query = (RepositoryTag
|
||||
.select(RepositoryTag, Image, ImageStorage)
|
||||
|
@ -1032,7 +1035,7 @@ def garbage_collect_repository(namespace_name, repository_name):
|
|||
storage.uuid)
|
||||
store.remove(image_path)
|
||||
|
||||
return len(to_remove)
|
||||
return len(to_remove)
|
||||
|
||||
|
||||
def get_tag_image(namespace_name, repository_name, tag_name):
|
||||
|
|
Reference in a new issue