diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-04 01:08:59 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-04 01:34:30 +0900 |
| commit | d76b9d04b813a361fc8e226480e3b66ca0208d41 (patch) | |
| tree | 5489463bedf7ec016ffad12b2c2c228afff83dbc /internal/pkg/pkg_test.go | |
| parent | fa93476896700f990e303cf3f60caa77f30df625 (diff) | |
internal/pkg: implement tar artifact
This is useful for unpacking tarballs downloaded from the internet.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg_test.go')
| -rw-r--r-- | internal/pkg/pkg_test.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index 6f4a256a..12b0bd9f 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -1,6 +1,7 @@ package pkg_test import ( + "archive/tar" "bytes" "crypto/sha512" "encoding/binary" @@ -40,7 +41,7 @@ func TestIdent(t *testing.T) { want pkg.ID }{ {"tar", pkg.KindTar, []byte{ - 1, 0, 0, 0, 0, 0, 0, 0, + pkg.TarGzip, 0, 0, 0, 0, 0, 0, 0, }, []pkg.Artifact{ stubArtifact{pkg.KindHTTP, pkg.ID{}}, }, pkg.MustDecode("HnySzeLQvSBZuTUcvfmLEX_OmH4yJWWH788NxuLuv7kVn8_uPM6Ks4rqFWM2NZJY")}, @@ -74,6 +75,7 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + t.Helper() t.Parallel() base := check.MustAbs(t.TempDir()) @@ -307,7 +309,7 @@ func TestCache(t *testing.T) { {"directory", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { id := pkg.KindTar.Ident( - binary.LittleEndian.AppendUint64(nil, 1), + binary.LittleEndian.AppendUint64(nil, pkg.TarGzip), stubArtifact{pkg.KindHTTP, testdataChecksum}, ) makeSample := func(work *check.Absolute) error { @@ -371,7 +373,7 @@ func TestCache(t *testing.T) { // check exist id0 := pkg.KindTar.Ident( - binary.LittleEndian.AppendUint64(nil, 1), + binary.LittleEndian.AppendUint64(nil, pkg.TarGzip), stubArtifact{pkg.KindHTTP, pkg.ID{}}, ) wantPathname0 := base.Append( @@ -478,6 +480,10 @@ func TestErrors(t *testing.T) { {"ResponseStatusError", pkg.ResponseStatusError( http.StatusNotAcceptable, ), "the requested URL returned non-OK status: Not Acceptable"}, + + {"DisallowedTypeflagError", pkg.DisallowedTypeflagError( + tar.TypeChar, + ), "disallowed typeflag '3'"}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { |
