internal/pkg: wrap checksum string encoding
All checks were successful
Test / Create distribution (push) Successful in 43s
Test / Sandbox (push) Successful in 2m36s
Test / ShareFS (push) Successful in 3m46s
Test / Hpkg (push) Successful in 4m24s
Test / Sandbox (race detector) (push) Successful in 4m53s
Test / Hakurei (race detector) (push) Successful in 5m48s
Test / Hakurei (push) Successful in 2m30s
Test / Flake checks (push) Successful in 1m45s

This wraps base64.URLEncoding.EncodeToString for cleaner call site.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-03 22:02:15 +09:00
parent 8ad9909065
commit 863d3dcf9f
2 changed files with 19 additions and 10 deletions

View File

@@ -3,7 +3,6 @@ package pkg_test
import (
"bytes"
"crypto/sha512"
"encoding/base64"
"io/fs"
"net/http"
"os"
@@ -51,8 +50,8 @@ func TestIdent(t *testing.T) {
if got := tc.kind.Ident(tc.params, tc.deps...); got != tc.want {
t.Errorf("Ident: %s, want %s",
base64.URLEncoding.EncodeToString(got[:]),
base64.URLEncoding.EncodeToString(tc.want[:]))
pkg.Encode(got),
pkg.Encode(tc.want))
}
})
}
@@ -132,7 +131,7 @@ func TestCache(t *testing.T) {
return (pkg.Checksum)(h.Sum(nil))
}()
testdataChecksumString := base64.URLEncoding.EncodeToString(testdataChecksum[:])
testdataChecksumString := pkg.Encode(testdataChecksum)
testCases := []cacheTestCase{
{"file", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) {
@@ -267,7 +266,7 @@ func TestCache(t *testing.T) {
var gotChecksum pkg.Checksum
wantPathnameG := base.Append(
"identifier",
base64.URLEncoding.EncodeToString(wantChecksum[:]),
pkg.Encode(wantChecksum),
)
if pathname, err := c.StoreFile(
wantChecksum,