fix(migrations): cancel GitLab version probes (#39023) (#39035)

Backport #39023 by @bircni

Bind the GitLab version probe to the migration context so a cancelled
migration does not remain blocked on a remote response.

Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
Giteabot
2026-08-22 01:52:31 -07:00
committed by GitHub
parent 9fe8653e45
commit 3f01f06d3b
2 changed files with 24 additions and 1 deletions
+23
View File
@@ -4,6 +4,7 @@
package migrations
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
@@ -359,6 +360,28 @@ func TestGitlabDownloadRepo(t *testing.T) {
}, rvs)
}
func TestGitlabVersionProbeUsesMigrationContext(t *testing.T) {
started := make(chan struct{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
close(started)
<-r.Context().Done()
}))
defer server.Close()
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
result := make(chan error, 1)
go func() {
_, err := NewGitlabDownloader(ctx, server.URL, "owner/repo", "")
result <- err
}()
<-started
cancel()
assert.Error(t, <-result)
}
func gitlabClientMockSetup(t *testing.T) (*http.ServeMux, *httptest.Server, *gitlab.Client) {
// mux is the HTTP request multiplexer used with the test server.
mux := http.NewServeMux()