internal/pkg: make checksum available to cure
All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m41s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hpkg (push) Successful in 5m37s
Test / Hakurei (push) Successful in 5m49s
Test / Hakurei (race detector) (push) Successful in 7m27s
Test / Flake checks (push) Successful in 1m43s
All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m41s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hpkg (push) Successful in 5m37s
Test / Hakurei (push) Successful in 5m49s
Test / Hakurei (race detector) (push) Successful in 7m27s
Test / Flake checks (push) Successful in 1m43s
This enables deduplication by value as implemented in execArtifact. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
"unique"
|
||||
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/internal/pkg"
|
||||
@@ -16,10 +17,10 @@ func TestHTTPGet(t *testing.T) {
|
||||
|
||||
const testdata = "\x7f\xe1\x69\xa2\xdd\x63\x96\x26\x83\x79\x61\x8b\xf0\x3f\xd5\x16\x9a\x39\x3a\xdb\xcf\xb1\xbc\x8d\x33\xff\x75\xee\x62\x56\xa9\xf0\x27\xac\x13\x94\x69"
|
||||
|
||||
testdataChecksum := func() pkg.Checksum {
|
||||
testdataChecksum := func() unique.Handle[pkg.Checksum] {
|
||||
h := sha512.New384()
|
||||
h.Write([]byte(testdata))
|
||||
return (pkg.Checksum)(h.Sum(nil))
|
||||
return unique.Make(pkg.Checksum(h.Sum(nil)))
|
||||
}()
|
||||
|
||||
var transport http.Transport
|
||||
@@ -33,7 +34,7 @@ func TestHTTPGet(t *testing.T) {
|
||||
f := pkg.NewHTTPGet(
|
||||
&client,
|
||||
"file:///testdata",
|
||||
testdataChecksum,
|
||||
testdataChecksum.Value(),
|
||||
)
|
||||
if got, err := f.Cure(t.Context()); err != nil {
|
||||
t.Fatalf("Cure: error = %v", err)
|
||||
@@ -48,7 +49,7 @@ func TestHTTPGet(t *testing.T) {
|
||||
pkg.Checksum{},
|
||||
)
|
||||
wantErrMismatch := &pkg.ChecksumMismatchError{
|
||||
Got: testdataChecksum,
|
||||
Got: testdataChecksum.Value(),
|
||||
}
|
||||
if _, err := f.Cure(t.Context()); !reflect.DeepEqual(err, wantErrMismatch) {
|
||||
t.Fatalf("Cure: error = %#v, want %#v", err, wantErrMismatch)
|
||||
@@ -70,7 +71,7 @@ func TestHTTPGet(t *testing.T) {
|
||||
f := pkg.NewHTTPGet(
|
||||
&client,
|
||||
"file:///testdata",
|
||||
testdataChecksum,
|
||||
testdataChecksum.Value(),
|
||||
)
|
||||
wantPathname := base.Append(
|
||||
"identifier",
|
||||
@@ -81,7 +82,7 @@ func TestHTTPGet(t *testing.T) {
|
||||
} else if !pathname.Is(wantPathname) {
|
||||
t.Fatalf("Cure: %q, want %q", pathname, wantPathname)
|
||||
} else if checksum != testdataChecksum {
|
||||
t.Fatalf("Cure: %x, want %x", checksum, testdataChecksum)
|
||||
t.Fatalf("Cure: %x, want %x", checksum.Value(), testdataChecksum.Value())
|
||||
}
|
||||
|
||||
if got, err := f.Cure(t.Context()); err != nil {
|
||||
@@ -94,7 +95,7 @@ func TestHTTPGet(t *testing.T) {
|
||||
f = pkg.NewHTTPGet(
|
||||
&client,
|
||||
"file:///testdata",
|
||||
testdataChecksum,
|
||||
testdataChecksum.Value(),
|
||||
)
|
||||
if got, err := f.Cure(t.Context()); err != nil {
|
||||
t.Fatalf("Cure: error = %v", err)
|
||||
|
||||
Reference in New Issue
Block a user