Quality improvements: Remove dead code, add unit tests, fix ignored errors

HIGH PRIORITY FIXES:
1. Remove unused progressCallback mechanism (dead code cleanup)
2. Add unit tests for restore package (formats, safety checks)
   - Test coverage for archive format detection
   - Test coverage for safety validation
   - Added NullLogger for testing
3. Fix ignored errors in backup pipeline
   - Handle StdoutPipe() errors properly
   - Log stderr pipe errors
   - Document CPU detection errors

IMPROVEMENTS:
- formats_test.go: 8 test functions, all passing
- safety_test.go: 6 test functions for validation
- logger/null.go: Test helper for unit tests
- Proper error handling in streaming compression
- Fixed indentation in stderr handling
This commit is contained in:
2025-11-07 11:47:07 +00:00
parent bf9a2b652a
commit 95ea807d18
8 changed files with 380 additions and 39 deletions

25
internal/logger/null.go Normal file
View File

@ -0,0 +1,25 @@
package logger
// NullLogger is a logger that discards all output (useful for testing)
type NullLogger struct{}
// NewNullLogger creates a new null logger
func NewNullLogger() *NullLogger {
return &NullLogger{}
}
func (l *NullLogger) Info(msg string, args ...any) {}
func (l *NullLogger) Warn(msg string, args ...any) {}
func (l *NullLogger) Error(msg string, args ...any) {}
func (l *NullLogger) Debug(msg string, args ...any) {}
func (l *NullLogger) Time(msg string, args ...any) {}
func (l *NullLogger) StartOperation(name string) OperationLogger {
return &nullOperation{}
}
type nullOperation struct{}
func (o *nullOperation) Update(msg string, args ...any) {}
func (o *nullOperation) Complete(msg string, args ...any) {}
func (o *nullOperation) Fail(msg string, args ...any) {}