mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-13 06:23:18 +00:00
refactor: improve error handling and variable naming in TestRunRollup
This commit is contained in:
committed by
Arik Jones (aider)
parent
364b185269
commit
a55e8df02a
@@ -89,37 +89,36 @@ func TestRunRollup(t *testing.T) {
|
|||||||
|
|
||||||
for name, content := range files {
|
for name, content := range files {
|
||||||
path := filepath.Join(tempDir, name)
|
path := filepath.Join(tempDir, name)
|
||||||
err := os.MkdirAll(filepath.Dir(path), 0755)
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Failed to create directory: %v", err)
|
t.Fatalf("Failed to create directory: %v", err)
|
||||||
}
|
}
|
||||||
err = os.WriteFile(path, []byte(content), 0644)
|
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Failed to write file: %v", err)
|
t.Fatalf("Failed to write file: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up test configuration
|
// Set up test configuration
|
||||||
cfg = &config.Config{
|
cfg := &config.Config{
|
||||||
FileTypes: []string{"go", "txt"},
|
FileTypes: []string{"go", "txt"},
|
||||||
Ignore: []string{"*.json"},
|
Ignore: []string{"*.json"},
|
||||||
CodeGenerated: []string{},
|
CodeGenerated: []string{},
|
||||||
}
|
}
|
||||||
path = tempDir
|
|
||||||
|
|
||||||
// Run the rollup
|
// Run the rollup
|
||||||
err = runRollup()
|
if err := runRollup(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("runRollup() failed: %v", err)
|
t.Fatalf("runRollup() failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the output file was created
|
// Check if the output file was created
|
||||||
files, _ := filepath.Glob(filepath.Join(tempDir, "*.rollup.md"))
|
outputFiles, err := filepath.Glob(filepath.Join(tempDir, "*.rollup.md"))
|
||||||
if len(files) == 0 {
|
if err != nil {
|
||||||
|
t.Fatalf("Error globbing for output file: %v", err)
|
||||||
|
}
|
||||||
|
if len(outputFiles) == 0 {
|
||||||
allFiles, _ := filepath.Glob(filepath.Join(tempDir, "*"))
|
allFiles, _ := filepath.Glob(filepath.Join(tempDir, "*"))
|
||||||
t.Fatalf("No rollup.md file found. Files in directory: %v", allFiles)
|
t.Fatalf("No rollup.md file found. Files in directory: %v", allFiles)
|
||||||
}
|
}
|
||||||
outputFile := files[0]
|
outputFile := outputFiles[0]
|
||||||
|
|
||||||
// Read the content of the output file
|
// Read the content of the output file
|
||||||
content, err := os.ReadFile(outputFile)
|
content, err := os.ReadFile(outputFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user