Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions domain/snyk/remediation/remy_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"os"
"os/exec"
"path/filepath"
"sync"
"sync/atomic"
Expand All @@ -35,42 +34,9 @@ import (
)

// ---------------------------------------------------------------------------
// Helpers
// Helpers (initGitRepo and commitFile are defined in remy_test.go)
// ---------------------------------------------------------------------------

// initGitRepo creates a temporary directory and initializes a new git repo in it.
func initGitRepo(t *testing.T) string {
t.Helper()
dir := t.TempDir()
for _, args := range [][]string{
{"init"},
{"config", "user.email", "test@test.com"},
{"config", "user.name", "Test"},
} {
cmd := exec.Command("git", append([]string{"-C", dir}, args...)...)
cmd.Stdout = nil
cmd.Stderr = nil
require.NoError(t, cmd.Run(), "git %v", args)
}
return dir
}

// commitFile writes content to name inside repo and commits it.
func commitFile(t *testing.T, repo, name, content string) {
t.Helper()
path := filepath.Join(repo, name)
require.NoError(t, os.WriteFile(path, []byte(content), 0644))
for _, args := range [][]string{
{"add", name},
{"commit", "-m", "add " + name},
} {
cmd := exec.Command("git", append([]string{"-C", repo}, args...)...)
cmd.Stdout = nil
cmd.Stderr = nil
require.NoError(t, cmd.Run(), "git %v", args)
}
}

// noopRunner is a fake remyRunner that makes no file changes.
func noopRunner(_ context.Context, _ workflow.Engine, _, _ string) error {
return nil
Expand Down
Loading
Loading