Fix deletion of robot accounts when attached to builds

Fixes #204
This commit is contained in:
Joseph Schorr 2015-06-30 22:35:28 +03:00
parent 7aeaf2344e
commit 3ba321934f
2 changed files with 16 additions and 4 deletions

View file

@ -2308,7 +2308,14 @@ class TestOrgRobots(ApiTestCase):
repo = model.get_repository(ORGANIZATION, ORG_REPO)
user = model.get_user(ADMIN_ACCESS_USER)
pull_robot = model.get_user(membername)
model.create_build_trigger(repo, 'fakeservice', 'sometoken', user, pull_robot=pull_robot)
trigger = model.create_build_trigger(repo, 'fakeservice', 'sometoken', user, pull_robot=pull_robot)
# Add a fake build of the fake build trigger.
token = model.create_access_token(repo, 'write', kind='build-worker',
friendly_name='Repository Build Token')
build = model.create_repository_build(repo, token, {}, 'fake-dockerfile', 'fake-name', trigger,
pull_robot_name=membername)
# Add some log entries for the robot.
model.log_action('pull_repo', ORGANIZATION, performer=pull_robot, repository=repo)
@ -2317,6 +2324,9 @@ class TestOrgRobots(ApiTestCase):
self.deleteResponse(OrgRobot,
params=dict(orgname=ORGANIZATION, robot_shortname='bender'))
# Verify the build is still present.
self.assertIsNotNone(model.get_repository_build(build.uuid))
# All the above records should now be deleted, along with the robot. We verify a few of the
# critical ones below.