test: change test commit file to actual file not temp file and use git add to add it

This commit is contained in:
Slug-Boi
2025-04-18 23:42:57 +02:00
committed by Theis
parent c7a9d3429d
commit ac1e59b7ee
+8 -1
View File
@@ -9,6 +9,7 @@ import (
"os"
"strings"
"testing"
"os/exec"
"github.com/Slug-Boi/cocommit/src/cmd/utils"
)
@@ -557,7 +558,7 @@ func Test_GitWrapper(t *testing.T) {
utils.Define_users("author_file_test")
// create a temporary file to test git wrapper
tmpFile, err := os.CreateTemp("", "test_git_wrapper")
tmpFile, err := os.Create("test_git_wrapper")
if err != nil {
t.Fatalf("Failed to create temporary file: %v", err)
}
@@ -581,6 +582,12 @@ func Test_GitWrapper(t *testing.T) {
authors := []string{"te"}
message := "Test commit message for GitWrapper"
cmd := exec.Command("git", "add", tmpFile.Name())
err = cmd.Run()
if err != nil {
t.Fatalf("Failed to run git add command: %v", err)
}
commit := utils.Commit(message, authors)
flags := []string{"-a","--dry-run"}