test(services): rename test files for MediaScanner
- Rename ebook_scanner_library_type_test.go -> media_scanner_library_type_test.go - Rename ebook_scanner_comic_test.go -> media_scanner_comic_test.go - Rename ebook_scanner_hash_test.go -> media_scanner_hash_test.go - Update test function names (TestEbookScanner* -> TestMediaScanner*) - Update ExampleEbookScanner_calculateFileSHA256 -> ExampleMediaScanner_calculateFileSHA256 - Update all EbookScanner references to MediaScanner in tests
This commit is contained in:
+10
-10
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
// TestCalculateFileSHA256 tests the SHA-256 calculation with streaming
|
||||
func TestCalculateFileSHA256(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
// Create a temporary test file
|
||||
tmpDir := t.TempDir()
|
||||
@@ -45,7 +45,7 @@ func TestCalculateFileSHA256(t *testing.T) {
|
||||
|
||||
// TestCalculateFileSHA256LargeFile tests streaming with large file
|
||||
func TestCalculateFileSHA256LargeFile(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
// Create a temporary test file with larger content
|
||||
tmpDir := t.TempDir()
|
||||
@@ -101,7 +101,7 @@ func TestCalculateFileSHA256LargeFile(t *testing.T) {
|
||||
|
||||
// TestExtractISBNFromIdentifier tests ISBN extraction
|
||||
func TestExtractISBNFromIdentifier(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -196,7 +196,7 @@ func TestIsValidUUID(t *testing.T) {
|
||||
|
||||
// TestDetermineHashConfidence tests confidence level determination
|
||||
func TestDetermineHashConfidence(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -248,7 +248,7 @@ func TestDetermineHashConfidence(t *testing.T) {
|
||||
|
||||
// TestDetectFormatType tests format type detection
|
||||
func TestDetectFormatType(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -304,7 +304,7 @@ func TestDetectFormatType(t *testing.T) {
|
||||
|
||||
// TestExtractHashInfo tests the complete hash extraction flow
|
||||
func TestExtractHashInfo(t *testing.T) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
// Create a temporary test file
|
||||
tmpDir := t.TempDir()
|
||||
@@ -349,7 +349,7 @@ func TestExtractHashInfo(t *testing.T) {
|
||||
|
||||
// BenchmarkCalculateFileSHA256 benchmarks SHA-256 calculation
|
||||
func BenchmarkCalculateFileSHA256(b *testing.B) {
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
// Create a temporary test file
|
||||
tmpDir := b.TempDir()
|
||||
@@ -372,7 +372,7 @@ func TestExtractHashInfoIntegration(t *testing.T) {
|
||||
t.Skip("Skipping integration test in short mode")
|
||||
}
|
||||
|
||||
scanner := &EbookScanner{}
|
||||
scanner := &MediaScanner{}
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
// Test multiple file types
|
||||
@@ -422,8 +422,8 @@ func TestExtractHashInfoIntegration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Example usage
|
||||
func ExampleEbookScanner_calculateFileSHA256() {
|
||||
scanner := &EbookScanner{}
|
||||
func ExampleMediaScanner_calculateFileSHA256() {
|
||||
scanner := &MediaScanner{}
|
||||
|
||||
// Calculate SHA-256 hash of a file
|
||||
hash, err := scanner.calculateFileSHA256("/path/to/ebook.epub")
|
||||
+17
-17
@@ -6,10 +6,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestEbookScanner_LibraryTypeAwareScanning tests Phase 2: library-type-aware scanning
|
||||
func TestEbookScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
// TestMediaScanner_LibraryTypeAwareScanning tests Phase 2: library-type-aware scanning
|
||||
func TestMediaScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
t.Run("isScannableFile checks library type restrictions", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/test/ebooks", "/test/comics"},
|
||||
libraryTypes: map[string][]string{
|
||||
"/test/ebooks": {".epub", ".mobi", ".azw3"},
|
||||
@@ -73,7 +73,7 @@ func TestEbookScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("isScannableFile case insensitive", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/test/ebooks"},
|
||||
libraryTypes: map[string][]string{
|
||||
"/test/ebooks": {".epub"},
|
||||
@@ -99,7 +99,7 @@ func TestEbookScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("isScannableFile with no library type info", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/test/ebooks"},
|
||||
libraryTypes: map[string][]string{}, // Empty library types
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func TestEbookScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("isScannableFile handles subdirectories", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/test/ebooks"},
|
||||
libraryTypes: map[string][]string{
|
||||
"/test/ebooks": {".epub"},
|
||||
@@ -121,13 +121,13 @@ func TestEbookScanner_LibraryTypeAwareScanning(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestEbookScanner_SetFolders_BuildsLibraryTypeCache tests Phase 2: SetFolders builds cache
|
||||
func TestEbookScanner_SetFolders_BuildsLibraryTypeCache(t *testing.T) {
|
||||
// TestMediaScanner_SetFolders_BuildsLibraryTypeCache tests Phase 2: SetFolders builds cache
|
||||
func TestMediaScanner_SetFolders_BuildsLibraryTypeCache(t *testing.T) {
|
||||
// This is a unit test that verifies SetFolders properly initializes the libraryTypes cache
|
||||
// Full integration testing would require a mock database
|
||||
|
||||
t.Run("SetFolders initializes libraryTypes map", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
libraryTypes: nil,
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestEbookScanner_SetFolders_BuildsLibraryTypeCache(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("SetFolders clears old library types", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
libraryTypes: map[string][]string{
|
||||
"/old/folder": {".epub"},
|
||||
},
|
||||
@@ -150,10 +150,10 @@ func TestEbookScanner_SetFolders_BuildsLibraryTypeCache(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestEbookScanner_LibraryTypeCrossContamination tests Phase 2: prevents cross-contamination
|
||||
func TestEbookScanner_LibraryTypeCrossContamination(t *testing.T) {
|
||||
// TestMediaScanner_LibraryTypeCrossContamination tests Phase 2: prevents cross-contamination
|
||||
func TestMediaScanner_LibraryTypeCrossContamination(t *testing.T) {
|
||||
t.Run("Ebook library rejects comic formats", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/library/ebooks"},
|
||||
libraryTypes: map[string][]string{
|
||||
"/library/ebooks": {".epub", ".mobi", ".azw3", ".pdf"},
|
||||
@@ -169,7 +169,7 @@ func TestEbookScanner_LibraryTypeCrossContamination(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Comic library rejects ebook formats", func(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{"/library/comics"},
|
||||
libraryTypes: map[string][]string{
|
||||
"/library/comics": {".cbz", ".cbr", ".cb7", ".cbt"},
|
||||
@@ -185,9 +185,9 @@ func TestEbookScanner_LibraryTypeCrossContamination(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestEbookScanner_MultipleLibraryTypes tests Phase 2: multiple libraries with different types
|
||||
func TestEbookScanner_MultipleLibraryTypes(t *testing.T) {
|
||||
scanner := &EbookScanner{
|
||||
// TestMediaScanner_MultipleLibraryTypes tests Phase 2: multiple libraries with different types
|
||||
func TestMediaScanner_MultipleLibraryTypes(t *testing.T) {
|
||||
scanner := &MediaScanner{
|
||||
folders: []string{
|
||||
"/library/ebooks",
|
||||
"/library/comics",
|
||||
Reference in New Issue
Block a user