Files
Roger a734e777a8 refactor(app): export one function per command (#712)
* refactor(app): export one function per command

Step 2 of #710. A command's logic was split between cmd and stage-shaped app calls; cmd now parses flags, calls one function and prints what it returns. An error means the command never ran, and a run that ended early says so in Summary.Err.

* fix(app): check dumpkeys and archive -o up front

A missing output directory was reported only after the keys were retrieved or the files copied.

* docs(rfcs): move restore's input out of the command layer

Restore now discovers its directories in an archive itself, so the command layer no longer holds the data it reads.
2026-11-22 14:45:39 +08:00

27 lines
686 B
Go

package browsertest
import (
"io/fs"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"github.com/moond4rk/hackbrowserdata/internal/zipfile"
)
// ZipDir packs every file under dir into archivePath, the way an archive carries a restore's data.
func ZipDir(t *testing.T, dir, archivePath string) {
t.Helper()
var names []string
require.NoError(t, filepath.WalkDir(dir, func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {
return err
}
relativePath, err := filepath.Rel(dir, path)
names = append(names, filepath.ToSlash(relativePath))
return err
}))
require.NoError(t, zipfile.Write(archivePath, dir, names))
}