daemon: seed repo volume via CopyToContainer (host-path bind bug → empty workspace); web: spawn poll reads fresh session list
This commit is contained in:
+25
-6
@@ -44,11 +44,12 @@ type recordedCreate struct {
|
||||
type fakeDocker struct {
|
||||
mu sync.Mutex
|
||||
|
||||
calls []dockerCall
|
||||
images int // entries served by GET /images/json
|
||||
volume map[string]bool // existing volumes
|
||||
nextID int
|
||||
create []recordedCreate
|
||||
calls []dockerCall
|
||||
images int // entries served by GET /images/json
|
||||
volume map[string]bool // existing volumes
|
||||
nextID int
|
||||
create []recordedCreate
|
||||
archives []int // sizes of accepted CopyToContainer tar streams
|
||||
|
||||
failBuild bool
|
||||
failBuildHTTP bool
|
||||
@@ -57,6 +58,8 @@ type fakeDocker struct {
|
||||
failStop bool
|
||||
failWait bool
|
||||
failVolumeCreate bool
|
||||
failArchive bool
|
||||
archiveHang bool
|
||||
waitHang bool
|
||||
|
||||
unknown []string
|
||||
@@ -241,6 +244,20 @@ func (f *fakeDocker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
writeJSONNow(w, http.StatusOK, `{"StatusCode":0,"Error":null}`)
|
||||
case call.Method == http.MethodPut && strings.HasSuffix(call.Path, "/archive"):
|
||||
// CopyToContainer: accept the tar stream and record its size.
|
||||
if f.archiveHang {
|
||||
<-r.Context().Done()
|
||||
return
|
||||
}
|
||||
if f.failArchive {
|
||||
writeJSONNow(w, http.StatusInternalServerError, `{"message":"archive failed"}`)
|
||||
return
|
||||
}
|
||||
f.mu.Lock()
|
||||
f.archives = append(f.archives, len(body))
|
||||
f.mu.Unlock()
|
||||
w.WriteHeader(http.StatusOK)
|
||||
case call.Method == http.MethodDelete && strings.HasPrefix(call.Path, "/containers/"):
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
default:
|
||||
@@ -273,11 +290,13 @@ func useFakeGit(t *testing.T, mode string) string {
|
||||
" noisy) printf '%s\\n' \"" + strings.Repeat("x", 600) + "\"; exit 1;;\n" +
|
||||
" silent) exit 1;;\n" +
|
||||
"esac\n" +
|
||||
"# clone: create a real worktree so seeding (tarDir) has files to copy\n" +
|
||||
"if [ \"$1\" = clone ]; then d=$(eval \"echo \\${$#}\"); mkdir -p \"$d\" && printf 'fake-repo\n' > \"$d/README.md\"; fi\n" +
|
||||
"exit 0\n"
|
||||
if err := os.WriteFile(filepath.Join(dir, "git"), []byte(script), 0o755); err != nil {
|
||||
t.Fatalf("write fake git: %v", err)
|
||||
}
|
||||
t.Setenv("PATH", dir)
|
||||
t.Setenv("PATH", dir+":"+os.Getenv("PATH"))
|
||||
t.Setenv("FAKE_GIT_MODE", mode)
|
||||
return logPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user