fix(library): expose scan activity and failed analysis file details
ci / api / api (push) Successful in 55s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m6s
ci / db / db (push) Successful in 52s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m38s
release / android (APK в релиз) (push) Successful in 3m50s
ci / ts / ts (packages + web) (push) Successful in 3m20s
release / release (версия и заметки) (push) Successful in 5s
release / desktop (Linux и Windows в релиз) (push) Successful in 44m45s
release / prune (старые файлы и прогоны) (push) Successful in 7s
ci / api / api (push) Successful in 55s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m6s
ci / db / db (push) Successful in 52s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m38s
release / android (APK в релиз) (push) Successful in 3m50s
ci / ts / ts (packages + web) (push) Successful in 3m20s
release / release (версия и заметки) (push) Successful in 5s
release / desktop (Linux и Windows в релиз) (push) Successful in 44m45s
release / prune (старые файлы и прогоны) (push) Successful in 7s
This commit is contained in:
1 parent
17b6dd2041
commit
0dc0384c78
20 files changed
+1114
-326
No files matched your search
@@ -55,7 +55,7 @@ func TestWalkAndHash(t *testing.T) {
|
||||
write("_incoming/new.mp3", 10)
|
||||
write("big.mp3", 3<<20)
|
||||
|
||||
found, err := walk(root, func(rel string) bool { return rel == "_incoming/new.mp3" })
|
||||
found, err := walk(root, func(rel string) bool { return rel == "_incoming/new.mp3" }, nil)
|
||||
require.NoError(t, err)
|
||||
assert.ElementsMatch(t, []string{"Artist/Album/01 - Song.FLAC", "big.mp3"}, rels(found))
|
||||
for _, w := range found {
|
||||
@@ -69,10 +69,42 @@ func TestWalkAndHash(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, h1, h2, "hash survives a rename")
|
||||
|
||||
_, err = walk(filepath.Join(root, "nope"), func(string) bool { return false })
|
||||
_, err = walk(filepath.Join(root, "nope"), func(string) bool { return false }, nil)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestWalkReportsIncrementalProgress(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
for _, dir := range []string{"a-empty", "b-album", ".hidden"} {
|
||||
require.NoError(t, os.MkdirAll(filepath.Join(root, dir), 0o755))
|
||||
}
|
||||
for _, rel := range []string{"b-album/1.mp3", "b-album/2.flac", "b-album/skip.mp3", ".hidden/3.mp3"} {
|
||||
require.NoError(t, os.WriteFile(filepath.Join(root, filepath.FromSlash(rel)), []byte("audio"), 0o644))
|
||||
}
|
||||
var counts, folders []int
|
||||
var paths []string
|
||||
found, err := walk(root, func(rel string) bool { return rel == "b-album/skip.mp3" }, func(n, dirs int, path string) {
|
||||
counts, folders, paths = append(counts, n), append(folders, dirs), append(paths, path)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, found, 2)
|
||||
assert.Equal(t, []int{0, 0, 0, 1, 2}, counts, "reports activity before any file is found and after each accepted audio file")
|
||||
assert.Equal(t, []int{1, 2, 3, 3, 3}, folders)
|
||||
assert.Equal(t, []string{".", "a-empty", "b-album", "b-album", "b-album"}, paths)
|
||||
}
|
||||
|
||||
func TestProgressDTOIncludesWalkActivity(t *testing.T) {
|
||||
p := Progress{Phase: "walking", Running: true, Found: 7, WalkedDirs: 4, CurrentDir: "Artist/Album"}
|
||||
dto := progressDTO(p)
|
||||
require.NotNil(t, dto.Phase)
|
||||
assert.Equal(t, "walking", string(*dto.Phase))
|
||||
assert.Equal(t, p.Found, dto.Found)
|
||||
require.NotNil(t, dto.WalkedDirs)
|
||||
assert.Equal(t, p.WalkedDirs, *dto.WalkedDirs)
|
||||
require.NotNil(t, dto.CurrentDir)
|
||||
assert.Equal(t, p.CurrentDir, *dto.CurrentDir)
|
||||
}
|
||||
|
||||
func TestParseFFprobe(t *testing.T) {
|
||||
raw := []byte(`{
|
||||
"streams": [
|
||||
|
||||
Reference in new issue
Block a user