summaryrefslogtreecommitdiff
path: root/internal/model/scan_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-17 15:25:52 +0300
committerPaul Buetow <paul@buetow.org>2026-05-17 15:25:52 +0300
commit914bd7cd6aa14e839332a98d91c30b19865b0cf2 (patch)
tree02b11537237a204048589e14ed24938b805e42f7 /internal/model/scan_test.go
parent3b24f0e1be832584d6550e8cc3e5d24329f66f90 (diff)
Restructure repo: move Go server into player-server/
Diffstat (limited to 'internal/model/scan_test.go')
-rw-r--r--internal/model/scan_test.go157
1 files changed, 0 insertions, 157 deletions
diff --git a/internal/model/scan_test.go b/internal/model/scan_test.go
deleted file mode 100644
index 7d370c3..0000000
--- a/internal/model/scan_test.go
+++ /dev/null
@@ -1,157 +0,0 @@
-package model
-
-import (
- "errors"
- "sync"
- "testing"
-)
-
-func TestScanProgress_Start(t *testing.T) {
- var p ScanProgress
- p.Start(3)
- cp := p.Copy()
- if !cp.Running {
- t.Error("expected Running to be true")
- }
- if cp.SetsTotal != 3 {
- t.Errorf("SetsTotal = %d, want 3", cp.SetsTotal)
- }
- if cp.SetsDone != 0 {
- t.Errorf("SetsDone = %d, want 0", cp.SetsDone)
- }
- if cp.FilesTotal != 0 {
- t.Errorf("FilesTotal = %d, want 0", cp.FilesTotal)
- }
- if cp.FilesDone != 0 {
- t.Errorf("FilesDone = %d, want 0", cp.FilesDone)
- }
- if cp.LastError != "" {
- t.Errorf("LastError = %q, want empty", cp.LastError)
- }
-}
-
-func TestScanProgress_SetCurrentSet(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- p.SetCurrentSet("movies")
- cp := p.Copy()
- if cp.CurrentSet != "movies" {
- t.Errorf("CurrentSet = %q, want movies", cp.CurrentSet)
- }
-}
-
-func TestScanProgress_SetFilesTotal(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- p.SetFilesTotal(42)
- cp := p.Copy()
- if cp.FilesTotal != 42 {
- t.Errorf("FilesTotal = %d, want 42", cp.FilesTotal)
- }
-}
-
-func TestScanProgress_AddFilesTotal(t *testing.T) {
- var p ScanProgress
- p.Start(2)
- p.AddFilesTotal(10)
- p.AddFilesTotal(15)
- cp := p.Copy()
- if cp.FilesTotal != 25 {
- t.Errorf("FilesTotal = %d, want 25", cp.FilesTotal)
- }
-}
-
-func TestScanProgress_IncrementFile(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- p.IncrementFile()
- cp := p.Copy()
- if cp.FilesDone != 1 {
- t.Errorf("FilesDone = %d, want 1", cp.FilesDone)
- }
-}
-
-func TestScanProgress_IncrementSet(t *testing.T) {
- var p ScanProgress
- p.Start(2)
- p.IncrementSet()
- cp := p.Copy()
- if cp.SetsDone != 1 {
- t.Errorf("SetsDone = %d, want 1", cp.SetsDone)
- }
-}
-
-func TestScanProgress_Done(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- p.Done(nil)
- cp := p.Copy()
- if cp.Running {
- t.Error("expected Running to be false")
- }
- if cp.CurrentSet != "" {
- t.Errorf("CurrentSet = %q, want empty", cp.CurrentSet)
- }
- if cp.LastError != "" {
- t.Errorf("LastError = %q, want empty", cp.LastError)
- }
-}
-
-func TestScanProgress_Done_WithError(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- p.Done(errors.New("scan failed"))
- cp := p.Copy()
- if cp.LastError != "scan failed" {
- t.Errorf("LastError = %q, want \"scan failed\"", cp.LastError)
- }
-}
-
-func TestScanProgress_Copy_Isolation(t *testing.T) {
- var p ScanProgress
- p.Start(1)
- cp1 := p.Copy()
- p.IncrementSet()
- cp2 := p.Copy()
-
- if cp1.SetsDone != 0 {
- t.Errorf("cp1.SetsDone = %d, want 0", cp1.SetsDone)
- }
- if cp2.SetsDone != 1 {
- t.Errorf("cp2.SetsDone = %d, want 1", cp2.SetsDone)
- }
-}
-
-func TestScanProgress_ConcurrentAccess(t *testing.T) {
- var p ScanProgress
- p.Start(2)
- p.SetFilesTotal(100)
-
- start := make(chan struct{})
- done := make(chan struct{})
- var copies sync.WaitGroup
- go func() {
- <-start
- for i := 0; i < 50; i++ {
- p.IncrementFile()
- }
- close(done)
- }()
-
- for i := 0; i < 50; i++ {
- copies.Add(1)
- go func() {
- defer copies.Done()
- <-start
- _ = p.Copy()
- }()
- }
- close(start)
- copies.Wait()
- <-done
-
- cp := p.Copy()
- if cp.FilesDone != 50 {
- t.Errorf("FilesDone = %d, want 50", cp.FilesDone)
- }
-}