Skip to content

Commit

Permalink
testutil/pkgdata: Add MakeTestDeb() (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
woky authored Aug 29, 2023
1 parent a6e7c43 commit 5e8cdac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/testutil/pkgdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,11 @@ func MakeDeb(entries []TarEntry) ([]byte, error) {
}
return buf.Bytes(), nil
}

func MustMakeDeb(entries []TarEntry) []byte {
data, err := MakeDeb(entries)
if err != nil {
panic(err)
}
return data
}
12 changes: 12 additions & 0 deletions internal/testutil/pkgdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,15 @@ func (s *pkgdataSuite) TestMakeDeb(c *C) {
_, err = arReader.Next()
c.Assert(err, Equals, io.EOF)
}

func (s *S) TestMustMakeDeb(c *C) {
defer func() {
err := recover()
c.Assert(err, ErrorMatches, `.*: cannot encode header: invalid PAX record: "path = \\x00./foo.*`)
}()
testutil.MustMakeDeb([]testutil.TarEntry{{
Header: tar.Header{
Name: "\000./foo",
},
}})
}

0 comments on commit 5e8cdac

Please sign in to comment.