Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testutil/pkgdata: Add TarEntry shorthand constructors
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