I would like suggestions on how TDD would approach this problem. Sorry if it seems too long, but this was a real task and there was much more which I did not include. I suppose the obvious thing is to call this an epic, and reduce it to stories, but I don't think it could be so simple. During development, I created several test functions, and manually ran them consistently with development. My solution has been in production six months and has done the Right Thing on over 400K documents.
Design and code a file management system such that:
The solution iteratively receives a single PDF and parameters including: {file category [A, B], file subcategory [S1, S2, S3, S4], file version (one or two chars)}. Example:
file123.pdf, A, S4, X.Copy each PDF to a repository. The path to the repository root must be retrieved from a config database. If the repository root does not exist or cannot be reached, the solution will not be able to create it, nor be able to copy any files.
If the repository does exist and can be reached, copy each file to a destination somewhere below the repository root. Grow the repo dynamically, organizing the file destination by file category, subcategory and one or more sequentially numbered subdirectories containing PDF's. Example:
A/S1/1, A/S1/2, A/S1/3, etc.Each PDF subdirectory must contain a single index file containing one unique line for each PDF.
Index line format is:{filename prefix, underscore, subcategory, underscore, version, .pdf}.Example:
file123_S4_X.pdf.File category [A, B] is not part of the file name nor of the index entry.
Each PDF directory may not exceed a maximum aggregate size, defined in a configuration database. The aggregate size must account for all PDF's in the directory plus the size of the index file.