diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-02-04 14:41:18 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-02-05 08:24:09 +0900 |
| commit | e0c720681bbce364910df241658dc987851e579a (patch) | |
| tree | bdbfbd67f26d562e8f1b2b2980a4bde6a10c94cc /internal/pkg/tar_test.go | |
| parent | f982b13a59a59e22d1ff3fdf791c1aa86b9420df (diff) | |
internal/pkg: standardise artifact IR
This should hopefully provide good separation between the artifact curing backend implementation and the (still work in progress) language. Making the IR parseable also guarantees uniqueness of the representation.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/tar_test.go')
| -rw-r--r-- | internal/pkg/tar_test.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/internal/pkg/tar_test.go b/internal/pkg/tar_test.go index 3e611df6..26a67d6c 100644 --- a/internal/pkg/tar_test.go +++ b/internal/pkg/tar_test.go @@ -40,7 +40,7 @@ func TestTar(t *testing.T) { }, pkg.MustDecode( "cTw0h3AmYe7XudSoyEMByduYXqGi-N5ZkTZ0t9K5elsu3i_jNIVF5T08KR1roBFM", )) - }, pkg.MustDecode("nnOiyjjjvgZChsGtO4rA1JHckwYBBbxwNfecPJp62OFP6aoYUxHQ5UtYsrDpnwan")}, + }, pkg.MustDecode("NQTlc466JmSVLIyWklm_u8_g95jEEb98PxJU-kjwxLpfdjwMWJq0G8ze9R4Vo1Vu")}, {"http expand", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { checkTarHTTP(t, base, c, fstest.MapFS{ @@ -51,7 +51,7 @@ func TestTar(t *testing.T) { }, pkg.MustDecode( "CH3AiUrCCcVOjOYLaMKKK1Da78989JtfHeIsxMzWOQFiN4mrCLDYpoDxLWqJWCUN", )) - }, pkg.MustDecode("bQVH19N7dX50SdQ6JNVYbFdDZV4t8IaM4dhxGvjACpdoEgJ2jZJfYKLH4ya7ZD_s")}, + }, pkg.MustDecode("hSoSSgCYTNonX3Q8FjvjD1fBl-E-BQyA6OTXro2OadXqbST4tZ-akGXszdeqphRe")}, }) } @@ -98,17 +98,36 @@ func checkTarHTTP( wantIdent := func() pkg.ID { h := sha512.New384() + + // kind uint64 h.Write([]byte{byte(pkg.KindTar), 0, 0, 0, 0, 0, 0, 0}) + // deps_sz uint64 + h.Write([]byte{1, 0, 0, 0, 0, 0, 0, 0}) + // kind uint64 h.Write([]byte{byte(pkg.KindHTTPGet), 0, 0, 0, 0, 0, 0, 0}) + // ident ID h0 := sha512.New384() + // kind uint64 h0.Write([]byte{byte(pkg.KindHTTPGet), 0, 0, 0, 0, 0, 0, 0}) - h0.Write(testdataChecksum[:]) + // deps_sz uint64 + h0.Write([]byte{0, 0, 0, 0, 0, 0, 0, 0}) + // url string + h0.Write([]byte{byte(pkg.IRKindString), 0, 0, 0}) + h0.Write([]byte{0x10, 0, 0, 0}) h0.Write([]byte("file:///testdata")) + // end(KnownChecksum) + h0.Write([]byte{byte(pkg.IRKindEnd), 0, 0, 0}) + h0.Write([]byte{byte(pkg.IREndKnownChecksum), 0, 0, 0}) + // checksum Checksum + h0.Write(testdataChecksum[:]) h.Write(h0.Sum(nil)) - - h.Write(make([]byte, len(pkg.Checksum{}))) - h.Write([]byte{pkg.TarGzip, 0, 0, 0, 0, 0, 0, 0}) + // compression uint32 + h.Write([]byte{byte(pkg.IRKindUint32), 0, 0, 0}) + h.Write([]byte{pkg.TarGzip, 0, 0, 0}) + // end + h.Write([]byte{byte(pkg.IRKindEnd), 0, 0, 0}) + h.Write([]byte{0, 0, 0, 0}) return pkg.ID(h.Sum(nil)) }() |
