diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-05-17 13:07:12 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-05-17 15:56:53 +0900 |
| commit | 30eb0d6a613ad268f6805ccbcdcabf158e7f526f (patch) | |
| tree | 07e55baa52748fd139e183017eeb43f5f64cee59 /cmd/mbf/info_test.go | |
| parent | c2ff9c9fa55ea569a5e70ee90d2eb0b2ee2a0540 (diff) | |
internal/rosa: key metadata by string
For upcoming azalea integration. The API is quite ugly right now to ease migration.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf/info_test.go')
| -rw-r--r-- | cmd/mbf/info_test.go | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/cmd/mbf/info_test.go b/cmd/mbf/info_test.go index a7219e9c..e3120157 100644 --- a/cmd/mbf/info_test.go +++ b/cmd/mbf/info_test.go @@ -10,6 +10,7 @@ import ( "strings" "syscall" "testing" + "unique" "unsafe" "hakurei.app/internal/pkg" @@ -20,6 +21,13 @@ import ( func TestInfo(t *testing.T) { t.Parallel() + _, qemuVersion := rosa.Native().Load(rosa.Std, rosa.QEMU) + _, glibVersion := rosa.Native().Load(rosa.Std, rosa.GLib) + zlib, zlibVersion := rosa.Native().Load(rosa.Std, rosa.Zlib) + _, zstdVersion := rosa.Native().Load(rosa.Std, rosa.Zstd) + _, hakureiVersion := rosa.Native().Load(rosa.Std, rosa.Hakurei) + _, hakureiDistVersion := rosa.Native().Load(rosa.Std, rosa.HakureiDist) + testCases := []struct { name string args []string @@ -29,24 +37,24 @@ func TestInfo(t *testing.T) { wantErr any }{ {"qemu", []string{"qemu"}, nil, "", ` -name : qemu-` + rosa.Std.Version(rosa.QEMU) + ` +name : qemu-` + qemuVersion + ` description : a generic and open source machine emulator and virtualizer website : https://www.qemu.org -depends on : glib-` + rosa.Std.Version(rosa.GLib) + ` zstd-` + rosa.Std.Version(rosa.Zstd) + ` +depends on : glib-` + glibVersion + ` zstd-` + zstdVersion + ` `, nil}, {"multi", []string{"hakurei", "hakurei-dist"}, nil, "", ` -name : hakurei-` + rosa.Std.Version(rosa.Hakurei) + ` +name : hakurei-` + hakureiVersion + ` description : low-level userspace tooling for Rosa OS website : https://hakurei.app -name : hakurei-dist-` + rosa.Std.Version(rosa.HakureiDist) + ` +name : hakurei-dist-` + hakureiDistVersion + ` description : low-level userspace tooling for Rosa OS (distribution tarball) website : https://hakurei.app `, nil}, {"nonexistent", []string{"zlib", "\x00"}, nil, "", ` -name : zlib-` + rosa.Std.Version(rosa.Zlib) + ` +name : zlib-` + zlibVersion + ` description : lossless data-compression library website : https://zlib.net @@ -56,12 +64,12 @@ website : https://zlib.net "zstd": "internal/pkg (amd64) on satori\n", "hakurei": "internal/pkg (amd64) on satori\n\n", }, "", ` -name : zlib-` + rosa.Std.Version(rosa.Zlib) + ` +name : zlib-` + zlibVersion + ` description : lossless data-compression library website : https://zlib.net status : not yet cured -name : zstd-` + rosa.Std.Version(rosa.Zstd) + ` +name : zstd-` + zstdVersion + ` description : a fast compression algorithm website : https://facebook.github.io/zstd status : internal/pkg (amd64) on satori @@ -70,19 +78,19 @@ status : internal/pkg (amd64) on satori {"status cache perm", []string{"zlib"}, map[string]string{ "zlib": "\x00", }, "", ` -name : zlib-` + rosa.Std.Version(rosa.Zlib) + ` +name : zlib-` + zlibVersion + ` description : lossless data-compression library website : https://zlib.net `, func(cm *cache) error { return &os.PathError{ Op: "open", - Path: filepath.Join(cm.base, "status", pkg.Encode(cm.c.Ident(rosa.Std.Load(rosa.Zlib)).Value())), + Path: filepath.Join(cm.base, "status", pkg.Encode(cm.c.Ident(zlib).Value())), Err: syscall.EACCES, } }}, {"status report", []string{"zlib"}, nil, strings.Repeat("\x00", len(pkg.Checksum{})+8), ` -name : zlib-` + rosa.Std.Version(rosa.Zlib) + ` +name : zlib-` + zlibVersion + ` description : lossless data-compression library website : https://zlib.net status : not in report @@ -131,8 +139,8 @@ status : not in report if tc.status != nil { for name, status := range tc.status { - p, ok := rosa.ResolveName(name) - if !ok { + a, _ := rosa.Native().Load(rosa.Std, rosa.ArtifactH(unique.Make(name))) + if a == nil { t.Fatalf("invalid name %q", name) } perm := os.FileMode(0400) @@ -143,7 +151,7 @@ status : not in report return os.WriteFile(filepath.Join( cm.base, "status", - pkg.Encode(cache.Ident(rosa.Std.Load(p)).Value()), + pkg.Encode(cache.Ident(a).Value()), ), unsafe.Slice(unsafe.StringData(status), len(status)), perm) }); err != nil { t.Fatalf("Do: error = %v", err) |
