package tools import ( "context" "os" "path/filepath" "testing" "time" "vidarchive/internal/config" "vidarchive/internal/util" ) // TestLiveInstall downloads the real releases. It catches the failure the unit // tests cannot: an asset renamed or dropped from a release, which turns the // install into a 404 or a missing checksum entry. // // VIDARCHIVE_ONLINE_TESTS=1 go test ./internal/tools -run Live -v func TestLiveInstall(t *testing.T) { if os.Getenv("VIDARCHIVE_ONLINE_TESTS") != "1" { t.Skip("set VIDARCHIVE_ONLINE_TESTS=1 to run") } dir := t.TempDir() cfg := &config.Config{ BinDir: dir, YTDLPPath: filepath.Join(dir, "yt-dlp"), YTDLPManaged: true, DenoPath: filepath.Join(dir, "deno"), DenoManaged: true, } m := New(cfg) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() if err := m.Ensure(ctx, true); err != nil { t.Fatalf("Ensure: %v", err) } for _, tool := range []struct{ path, arg string }{ {cfg.YTDLPPath, "--version"}, {cfg.DenoPath, "--version"}, } { out, err := util.KillableCommand(ctx, tool.path, tool.arg).CombinedOutput() if err != nil { t.Errorf("%s %s: %v: %s", tool.path, tool.arg, err, out) continue } t.Logf("%s -> %s", filepath.Base(tool.path), out) } }