Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
amenocal committed Feb 7, 2025
1 parent 0305f7b commit 43995d8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,35 @@ import (
func TestGetWorkflowFiles(t *testing.T) {
// Setup: create a temporary directory with test files
tempDir := t.TempDir()
os.MkdirAll(filepath.Join(tempDir, ".github", "workflows"), 0755)
err := os.MkdirAll(filepath.Join(tempDir, ".github", "workflows"), 0755)
if err != nil {
t.Fatalf("Unexpected error creating directory: %v", err)
}
testFiles := []string{
"workflow1.yml",
"workflow2.yaml",
"workflow-pin.yml",
"workflow-pin.yaml",
}
for _, file := range testFiles {
os.WriteFile(filepath.Join(tempDir, ".github", "workflows", file), []byte{}, 0644)
err := os.WriteFile(filepath.Join(tempDir, ".github", "workflows", file), []byte{}, 0644)
if err != nil {
t.Fatalf("Unexpected error writing file: %v", err)
}
}

// Override the directory for testing
originalDir, _ := os.Getwd()
defer func() { os.Chdir(originalDir) }()
os.Chdir(tempDir)
defer func() {
err := os.Chdir(originalDir)
if err != nil {
t.Fatalf("Unexpected error changing directory: %v", err)
}
}()
err = os.Chdir(tempDir)
if err != nil {
t.Fatalf("Unexpected error changing directory: %v", err)
}

workflowFiles, err := getWorkflowFiles()
if err != nil {
Expand Down

0 comments on commit 43995d8

Please sign in to comment.