MediaImporter / TEST_PLAN.md
Newer Older
85a3bb0 9 months ago History
140 lines | 6.791kb
Bogdan Timofte authored 9 months ago
1
# Media Importer Test Plan
2

            
3
## Purpose
4
This test plan ensures the reliability and correctness of `media-importer.sh` by covering key scenarios and edge cases.
5

            
6
## Test Areas
7
1. **Basic Functionality**
8
   - Organize media files by date using all supported organization patterns (`y`, `m`, `d`, `h`).
9
   - Move and copy modes (with and without `--keep-originals`).
10
   - Dry run mode (`--dry-run`).
11

            
12
2. **Source and Destination Handling**
13
   - Single and multiple source patterns (folders, globs, files).
14
   - Destination folder creation and error handling.
15
   - Exclusion of destination from source search.
16
   - Symlinked source directories.
17

            
18
3. **Error Handling**
19
   - Missing or invalid organization pattern.
20
   - Missing required dependencies (e.g., exiftool).
21
   - Unwritable destination directory.
22
   - Files with no EXIF/media date metadata (should be skipped or collected as unsortable).
23
   - Fatal errors (e.g., cannot generate destination path).
24
   - Recoverable errors (e.g., failed copy/move).
25

            
26
4. **Performance and Edge Cases**
27
   - Large number of files (10k+).
28
   - Files with conflicting names (should be renamed).
29
   - Mixed media types and extensions.
30
   - Files with unusual or missing extensions.
31

            
32
5. **Reporting**
33
   - Correct summary of processed, skipped, and error files.
34
   - Accurate size and speed reporting.
35
   - Verbose and non-verbose output modes.
36

            
37

            
38

            
39
## Sample Data Note
40
The `samples/media` directory contains files both with and without EXIF date metadata. Any test that does not correctly detect and handle files lacking EXIF dates (i.e., skips or collects them as unsortable) is considered failed.
41

            
42
## Test Directory Usage
43
To facilitate testing, the `tests` directory will be used as the working directory for all test scenarios. Before each test, relevant files will be copied from `samples/media` into `tests`. After inspecting the results, the `tests` directory will be cleaned to ensure a fresh state for the next test.
44

            
45
## Specific Test Cases
46

            
47
### TC01: Basic Organization Patterns
48
- **Objective**: Test all organization patterns (y, m, d, h)
49
- **Setup**: Copy sample files from `samples/media` to `tests/media`
50
- **Commands**:
51
  - `./media-importer.sh -s ./tests/media -d ./tests/sorted_y -o y`
52
  - `./media-importer.sh -s ./tests/media -d ./tests/sorted_m -o m`
53
  - `./media-importer.sh -s ./tests/media -d ./tests/sorted_d -o d`
54
  - `./media-importer.sh -s ./tests/media -d ./tests/sorted_h -o h`
55
- **Expected**: Files organized according to each pattern
56
- **Cleanup**: `rm -rf ./tests/*`
57

            
58
### TC02: Copy vs Move Mode
59
- **Objective**: Test --keep-originals flag
60
- **Setup**: Copy sample files to `tests/media`
61
- **Commands**:
62
  - `./media-importer.sh -s ./tests/media -d ./tests/copied -k`
63
  - `./media-importer.sh -s ./tests/media -d ./tests/moved`
64
- **Expected**: First command copies files, second moves them
65
- **Cleanup**: `rm -rf ./tests/*`
66

            
67
### TC03: Dry Run Mode
68
- **Objective**: Test --dry-run functionality
69
- **Setup**: Copy sample files to `tests/media`
70
- **Command**: `./media-importer.sh -s ./tests/media -d ./tests/dry --dry-run`
71
- **Expected**: Shows what would be done without moving files
72
- **Cleanup**: `rm -rf ./tests/*`
73

            
74
### TC04: Symlinked Source
75
- **Objective**: Test symlinked source directory
76
- **Setup**:
77
  - `mkdir -p tests/media`
78
  - `ln -sf ../samples/media tests/linked_media`
79
- **Command**: `./media-importer.sh -s ./tests/linked_media -d ./tests/from_symlink`
80
- **Expected**: Files from symlinked directory are processed
81
- **Cleanup**: `rm -rf ./tests/*`
82

            
83
### TC05: Error Handling - Invalid Pattern
84
- **Objective**: Test invalid organization pattern
85
- **Command**: `./media-importer.sh -o z`
86
- **Expected**: Error message and exit code 1
87
- **Cleanup**: None needed
88

            
89
### TC06: Same Source and Destination (Fatal Error)
90
- **Objective**: Test fatal error handling
91
- **Setup**: Copy sample files to `tests/media`
92
- **Command**: `./media-importer.sh -s ./tests -d ./tests`
93
- **Expected**: Fatal error stops processing immediately
94
- **Cleanup**: `rm -rf ./tests/*`
95

            
96
## New Feature: --full-date Argument & Default Flat Naming
97

            
98
### TC07: --full-date Argument (EXIF Date Required)
99
- **Objective**: Verify that only files with EXIF/media dates are processed and named with full date format.
100
- **Setup**: Copy sample files to `tests/media`
101
- **Command**: `./media-importer.sh --full-date -s ./tests/media -d ./tests/flat`
102
- **Expected**: Only files with EXIF dates in `tests/flat` named as `yyyy-mm-dd_hh-mm-ss.ext` (no subfolders). Files without EXIF dates remain in source.
103
- **Cleanup**: `rm -rf ./tests/*`
104

            
105
### TC08: No Organization Directive (EXIF Date Required)
106
- **Objective**: Verify that omitting the organization directive results in flat full-date naming for files with EXIF dates only.
107
- **Setup**: Copy sample files to `tests/media`
108
- **Command**: `./media-importer.sh -s ./tests/media -d ./tests/flat_default`
109
- **Expected**: Only files with EXIF dates in `tests/flat_default` named as `yyyy-mm-dd_hh-mm-ss.ext` (no subfolders). Files without EXIF dates remain in source.
110
- **Cleanup**: `rm -rf ./tests/*`
111

            
112
### TC09: Organization Directive with --full-date (EXIF Date Required)
113
- **Objective**: Verify that --full-date overrides any organization directive and processes only files with EXIF dates.
114
- **Setup**: Copy sample files to `tests/media`
115
- **Command**: `./media-importer.sh --full-date -o y -s ./tests/media -d ./tests/flat_override`
116
- **Expected**: Only files with EXIF dates in `tests/flat_override` named as `yyyy-mm-dd_hh-mm-ss.ext` (no subfolders). Files without EXIF dates remain in source.
117
- **Cleanup**: `rm -rf ./tests/*`
118

            
119
### TC10: --collect-unsortable Flag
120
- **Objective**: Verify that files without EXIF dates are moved to unsortable folder when flag is used.
121
- **Setup**: Copy sample files to `tests/media`
122
- **Command**: `./media-importer.sh --full-date --collect-unsortable -s ./tests/media -d ./tests/flat`
123
- **Expected**: Files with EXIF dates in `tests/flat` named as `yyyy-mm-dd_hh-mm-ss.ext`. Files without EXIF dates in `tests/flat/unsortable/`.
124
- **Cleanup**: `rm -rf ./tests/*`
125

            
126
### TC11: Basic Organization with EXIF Requirement
127
- **Objective**: Test that organization patterns only process files with EXIF dates.
128
- **Setup**: Copy sample files to `tests/media`
129
- **Command**: `./media-importer.sh -o y -s ./tests/media -d ./tests/sorted_y`
130
- **Expected**: Only files with EXIF dates organized by year. Files without EXIF dates remain in source.
131
- **Cleanup**: `rm -rf ./tests/*`
132

            
133
## Test Execution Framework
134
- Before each test: Prepare test data from `samples/media`
135
- Run test command and capture output
136
- Verify expected behavior and results
137
- After each test: Clean `tests` directory with `rm -rf ./tests/*`
138

            
139
---
140
This plan should be updated as new features or bug fixes are added.