Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add TarEntry shorthand constructors (#86)
Introduce shorthand constructors for testutil.TarEntry structures. These are Reg(), Dir() and Lnk() functions. The rationale for this addition is to make the test case definition less verbose. There are other changes in the queue that construct custom packages to test various test cases. In all these new tests (and old ones as well) we only care about file's type, path, mode and content. With these shorthand constructors and function aliases we can define tar entries like: Dir(0755, "./data/"), Reg(0600, "./data/document.txt", "words words words"), Lnk(0777, "./data/document", "document.txt"), Instead of: testutil.TarEntry{ Header: tar.Header{ Name: "./data/", Mode: 0755, }, }, testutil.TarEntry{ Header: tar.Header{ Name: "./document.txt", Mode: 0600, }, Content: []byte("words words words"), }, testutil.TarEntry{ Header: tar.Header{ Name: "./document.txt", Mode: 0777, Linkname: "document.txt", }, }, The reason for the 3 letter names and the order of arguments is to make the list of paths aligned on the same column in tarball definitions. These function only create barebone TarEntry. It'll still get adjusted when passed through fixupTarEntry().
- Loading branch information