WIP: feat: cancel git clone ops gracefully
Some checks failed
continuous-integration/drone/push Build is failing

See #528
This commit is contained in:
2025-04-22 12:40:31 +02:00
parent 229e8eb9da
commit 7218f309de
2 changed files with 86 additions and 21 deletions

37
pkg/git/clone_test.go Normal file
View File

@ -0,0 +1,37 @@
package git
import (
"fmt"
"os"
"path"
"syscall"
"testing"
"time"
"coopcloud.tech/abra/pkg/config"
)
func TestCancelGitClone(t *testing.T) {
dir := path.Join(config.RECIPES_DIR, "gitea")
os.RemoveAll(dir)
go func() {
time.Sleep(1 * time.Second)
p, err := os.FindProcess(os.Getpid())
if err != nil {
t.Fatalf("unable to find current process: %s", err)
}
p.Signal(syscall.SIGINT)
}()
gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "gitea")
if err := Clone(dir, gitURL); err == nil {
t.Fatal("cloning should have been interrupted")
}
if _, err := os.Stat(dir); !os.IsNotExist(err) {
t.Fatal("recipe directory should have been deleted")
}
}