Project

Profile

Help

Story #8454

Updated by bmbouter about 3 years ago

## Current State 

 You cannot delete version 0. That is enforced int the code [here](https://github.com/pulp/pulpcore/blob/348c654567067fb24bc13fa5105628433fb911fb/pulpcore/app/viewsets/repository.py#L222-L223). 

 ## Proposal 

 Allow users to be able to delete RepoVersion 0 if it is not the only RepoVersion. Due to the set-differencing data model in Pulp, RepositoryVersions must have at least one RepositoryVerison. 

 ## Implementation 

 1. The viewset should no longer prevent that RepositoryVersion 0 can be removed 
 2. A check needs to be added to the Delete Task that if the RepositoryVersion being deleted is the only remaining repository version an error is raised 
 3. Add tests (see below) 

 ## Add Tests 

 We need a functional test asserting the correctness around removing RepoVersion 0. Something like: 

 1. Create a repository 
 2. Put some content in it to create RepoVersion 1 
 3. Put more content in it to create Delete RepoVersion 2 0 
 4. Assert View the content counts for RepositoryVersion 2 
 5. Assert the content summary data from RepoVersion 2 
 6. Delete RepoVersion 0 
 7. Delete RepoVersion 1 
 8. Assert the content counts from RepoVersion 2 again, to ensure the content is still in-tact. 
 9. Assert the content summary data from RepoVersion 2 again, to ensure it is correct 

 We also need a functional test asserting that the only remaining repository version cannot be deleted. 

 1. Create a Repository 
 2. Try to delete repository 0 
 3. Assert the task fails.

Back