tools_live_test.go
⎇
Raw
1package tools
2
3import (
4 "context"
5 "os"
6 "path/filepath"
7 "testing"
8 "time"
9
10 "vidarchive/internal/config"
11 "vidarchive/internal/util"
12)
13
14// TestLiveInstall downloads the real releases. It catches the failure the unit
15// tests cannot: an asset renamed or dropped from a release, which turns the
16// install into a 404 or a missing checksum entry.
17//
18// VIDARCHIVE_ONLINE_TESTS=1 go test ./internal/tools -run Live -v
19func TestLiveInstall(t *testing.T) {
20 if os.Getenv("VIDARCHIVE_ONLINE_TESTS") != "1" {
21 t.Skip("set VIDARCHIVE_ONLINE_TESTS=1 to run")
22 }
23
24 dir := t.TempDir()
25 cfg := &config.Config{
26 BinDir: dir,
27 YTDLPPath: filepath.Join(dir, "yt-dlp"),
28 YTDLPManaged: true,
29 DenoPath: filepath.Join(dir, "deno"),
30 DenoManaged: true,
31 }
32 m := New(cfg)
33
34 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
35 defer cancel()
36
37 if err := m.Ensure(ctx, true); err != nil {
38 t.Fatalf("Ensure: %v", err)
39 }
40
41 for _, tool := range []struct{ path, arg string }{
42 {cfg.YTDLPPath, "--version"},
43 {cfg.DenoPath, "--version"},
44 } {
45 out, err := util.KillableCommand(ctx, tool.path, tool.arg).CombinedOutput()
46 if err != nil {
47 t.Errorf("%s %s: %v: %s", tool.path, tool.arg, err, out)
48 continue
49 }
50 t.Logf("%s -> %s", filepath.Base(tool.path), out)
51 }
52}
53