abra/pkg/git/clone_test.go
decentral1se 706d539dc4
Some checks reported errors
continuous-integration/drone/push Build was killed
WIP: feat: cancel git clone ops gracefully
See #528
2025-04-22 18:43:48 +02:00

37 lines
670 B
Go

package git
import (
"fmt"
"os"
"path"
"syscall"
"testing"
"time"
"coopcloud.tech/abra/pkg/config"
)
func TestCancelGitClone(t *testing.T) {
go func() {
time.Sleep(time.Second * 1)
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")
dir := path.Join(config.RECIPES_DIR, "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")
}
}