Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testutil/pkgdata: Add TarEntry shorthand constructors #86

Merged
merged 1 commit into from
Oct 12, 2023

Commits on Oct 9, 2023

  1. 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().
    woky committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    f836ca8 View commit details
    Browse the repository at this point in the history