mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 23:13:22 +00:00
fix: address functionality gaps identified in code review
- Wire up --config/-f flag to actually load custom config files - Move config loading to PersistentPreRunE in root.go - Simplify main.go to just call cmd.Execute() - Move Playwright init to web command's PreRunE/PostRunE - Remove unused functions from cmd/web.go (~90 lines of dead code) - Remove writeSingleFile, writeMultipleFiles, generateDefaultFilename - Remove scrapeURL, extractAndConvertContent, testExtractAndConvertContent - Remove unused mock function from web_test.go - Add OutputType validation to Config.Validate() - Only allow "single", "separate", or empty string - Add test cases for valid and invalid output types
This commit is contained in:
@@ -92,6 +92,10 @@ func (c *Config) Validate() error {
|
||||
return fmt.Errorf("file_extensions or sites must be specified")
|
||||
}
|
||||
|
||||
if c.OutputType != "" && c.OutputType != "single" && c.OutputType != "separate" {
|
||||
return fmt.Errorf("output_type must be 'single' or 'separate'")
|
||||
}
|
||||
|
||||
if c.RequestsPerSecond != nil && *c.RequestsPerSecond <= 0 {
|
||||
return fmt.Errorf("requests_per_second must be positive")
|
||||
}
|
||||
|
||||
@@ -136,6 +136,30 @@ func TestValidate(t *testing.T) {
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Valid output type single",
|
||||
config: Config{
|
||||
FileExtensions: []string{"go"},
|
||||
OutputType: "single",
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Valid output type separate",
|
||||
config: Config{
|
||||
FileExtensions: []string{"go"},
|
||||
OutputType: "separate",
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid output type",
|
||||
config: Config{
|
||||
FileExtensions: []string{"go"},
|
||||
OutputType: "invalid",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user