Add unit tests for checker/scanner and validate input paths
- Add comprehensive unit tests for internal/checker (88.5% coverage) - Status string representations - NewChecker validation - Check operation (OK, missing, size/hash mismatch) - Progress reporting and context cancellation - FindExtraFiles functionality - Add comprehensive unit tests for internal/scanner (80.1% coverage) - Constructors and options - File/path enumeration - Dotfile exclusion/inclusion - ToManifest with progress and cancellation - Non-blocking status channel sends - Validate input paths before scanning in generate command - Fail fast with clear error if paths don't exist - Prevents confusing errors deep in enumeration
This commit is contained in:
@@ -54,13 +54,18 @@ func (mfa *CLIApp) generateManifestOperation(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Collect all paths first
|
||||
// Collect and validate all paths first
|
||||
paths := make([]string, 0, args.Len())
|
||||
for i := 0; i < args.Len(); i++ {
|
||||
ap, err := filepath.Abs(args.Get(i))
|
||||
inputPath := args.Get(i)
|
||||
ap, err := filepath.Abs(inputPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Validate path exists before adding to list
|
||||
if exists, _ := afero.Exists(mfa.Fs, ap); !exists {
|
||||
return fmt.Errorf("path does not exist: %s", inputPath)
|
||||
}
|
||||
log.Debugf("enumerating path: %s", ap)
|
||||
paths = append(paths, ap)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user