Some checks failed
continuous-integration/drone/push Build is failing
See #528
38 lines
689 B
Go
38 lines
689 B
Go
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")
|
|
}
|
|
}
|