package opencode import ( "context" "errors" "os" "path/filepath" "runtime" "testing" "amadan.net/oficina/equipo/internal/runner/provider" ) // TestZZInstallFromCopies installs this platform's pinned OpenCode into // ZZ_ROOT from local copies of the two tarballs (ZZ_TARBALLS holding // cli.tgz and .tgz), through InstallPinned with the committed pins, and // prints the tree's digest: how a pin bump computes the new digests. func TestZZInstallFromCopies(t *testing.T) { dir, root := os.Getenv("ZZ_TARBALLS"), os.Getenv("ZZ_ROOT") if dir == "" || root == "" { t.Skip() } platform := platforms[runtime.GOARCH] cli, _ := Lock(PackageName) bin, _ := Lock(platform.Package) files := map[string]string{cli.Resolved: "cli.tgz", bin.Resolved: runtime.GOARCH + ".tgz"} fetch := func(_ context.Context, url string, _ int64) ([]byte, error) { name, ok := files[url] if !ok { return nil, errors.New("no such file") } return os.ReadFile(filepath.Join(dir, name)) } err := InstallPinned(context.Background(), root, runtime.GOARCH, fetch) tree, _ := Paths(root, platform.Package) sum, _ := provider.TreeSHA256(tree) t.Logf("INSTALL %v TREE %s", err, sum) }