| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | agentvm "github.com/sylvinus/agent-vm" |
| 8 | "github.com/sylvinus/agent-vm/internal/vm/vmtest" |
| 9 | ) |
| 10 | |
| 11 | func TestLicenses(t *testing.T) { |
| 12 | te := newTestEnv(t, vmtest.New()) |
| 13 | if code := te.run("licenses"); code != 0 || te.stderr.Len() != 0 { |
| 14 | t.Fatalf("licenses: %d\n%s", code, te.out()) |
| 15 | } |
| 16 | out := te.stdout.String() |
| 17 | |
| 18 | |
| 19 | for _, want := range []string{ |
| 20 | "MIT License", "Copyright (c) 2026 Sylvain Zimmer", |
| 21 | agentvm.Notice, |
| 22 | "github.com/lima-vm/lima/v2 ./third_party/lima: LICENSE", |
| 23 | "github.com/lima-vm/lima/v2 ./third_party/lima: NOTICE", |
| 24 | "github.com/lima-vm/sshocker ./third_party/sshocker: LICENSE", |
| 25 | "github.com/containers/gvisor-tap-vsock ./third_party/gvisor-tap-vsock: LICENSE", |
| 26 | "github.com/pkg/sftp ./third_party/sftp: LICENSE", |
| 27 | "golang.org/x/sys ", |
| 28 | "Go standard library", |
| 29 | "Apache License", |
| 30 | } { |
| 31 | if !strings.Contains(out, want) { |
| 32 | t.Errorf("the output lacks %q", want) |
| 33 | } |
| 34 | } |
| 35 | if te.run("licenses", "x") != 2 || !strings.Contains(te.out(), "Usage: agent-vm licenses") { |
| 36 | t.Errorf("an argument: %s", te.out()) |
| 37 | } |
| 38 | if te.run("--readonly", "licenses") != exitUsage { |
| 39 | t.Errorf("a VM option: %s", te.out()) |
| 40 | } |
| 41 | } |