oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package opencode
2
3import (
4 "context"
5 "errors"
6 "os"
7 "path/filepath"
8 "runtime"
9 "testing"
10
11 "amadan.net/oficina/equipo/internal/runner/provider"
12)
13
14// TestZZInstallFromCopies installs this platform's pinned OpenCode into
15// ZZ_ROOT from local copies of the two tarballs (ZZ_TARBALLS holding
16// cli.tgz and <goarch>.tgz), through InstallPinned with the committed pins, and
17// prints the tree's digest: how a pin bump computes the new digests.
18func TestZZInstallFromCopies(t *testing.T) {
19 dir, root := os.Getenv("ZZ_TARBALLS"), os.Getenv("ZZ_ROOT")
20 if dir == "" || root == "" {
21 t.Skip()
22 }
23 platform := platforms[runtime.GOARCH]
24 cli, _ := Lock(PackageName)
25 bin, _ := Lock(platform.Package)
26 files := map[string]string{cli.Resolved: "cli.tgz", bin.Resolved: runtime.GOARCH + ".tgz"}
27 fetch := func(_ context.Context, url string, _ int64) ([]byte, error) {
28 name, ok := files[url]
29 if !ok {
30 return nil, errors.New("no such file")
31 }
32 return os.ReadFile(filepath.Join(dir, name))
33 }
34 err := InstallPinned(context.Background(), root, runtime.GOARCH, fetch)
35 tree, _ := Paths(root, platform.Package)
36 sum, _ := provider.TreeSHA256(tree)
37 t.Logf("INSTALL %v TREE %s", err, sum)
38}
39