From ac1e59b7eea5da74da407394de16e750c9ee8727 Mon Sep 17 00:00:00 2001 From: Slug-Boi Date: Fri, 18 Apr 2025 23:42:57 +0200 Subject: [PATCH] test: change test commit file to actual file not temp file and use git add to add it --- src/cmd/utils/util_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cmd/utils/util_test.go b/src/cmd/utils/util_test.go index af52499..3418f69 100644 --- a/src/cmd/utils/util_test.go +++ b/src/cmd/utils/util_test.go @@ -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"}