fix(review round 1): daemon PAT-header auth, job pruning, session-split batches, streaming tars, seed cleanup, ping/pong, byte caps, branch switch, slug --, ctx cancel, Init:true, pagination, latest/before events; web newest-window history + load-older, offline busy gate, staleness guards, memo store, auth probe, scroll key, focus-visible, draft restore, poll dedup; 106+181 tests, coverage 96.2%/95.1%+
This commit is contained in:
+18
-2
@@ -4,6 +4,7 @@ package main
|
||||
// fake git binary (PATH shim recording invocations).
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -38,6 +39,7 @@ type recordedCreate struct {
|
||||
HostConfig struct {
|
||||
Binds []string `json:"Binds"`
|
||||
NetworkMode string `json:"NetworkMode"`
|
||||
Init *bool `json:"Init"`
|
||||
} `json:"HostConfig"`
|
||||
}
|
||||
|
||||
@@ -58,6 +60,7 @@ type fakeDocker struct {
|
||||
failStop bool
|
||||
failWait bool
|
||||
failVolumeCreate bool
|
||||
failVolumeDelete bool
|
||||
failArchive bool
|
||||
archiveHang bool
|
||||
waitHang bool
|
||||
@@ -205,6 +208,16 @@ func (f *fakeDocker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
writeJSONNow(w, http.StatusNotFound, `{"message":"no such volume"}`)
|
||||
case call.Method == http.MethodDelete && strings.HasPrefix(call.Path, "/volumes/"):
|
||||
if f.failVolumeDelete {
|
||||
writeJSONNow(w, http.StatusInternalServerError, `{"message":"volume delete failed"}`)
|
||||
return
|
||||
}
|
||||
name := strings.TrimPrefix(call.Path, "/volumes/")
|
||||
f.mu.Lock()
|
||||
delete(f.volume, name)
|
||||
f.mu.Unlock()
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
case call.Method == http.MethodPost && call.Path == "/containers/create":
|
||||
var rc recordedCreate
|
||||
if err := json.Unmarshal(body, &rc); err != nil {
|
||||
@@ -290,8 +303,11 @@ 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" +
|
||||
"# branch probe: emit the configured HEAD name\n" +
|
||||
"if [ \"$1\" = '-C' ] && [ \"$3\" = rev-parse ]; then printf '%s' \"$FAKE_GIT_HEAD\"; exit 0; fi\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" +
|
||||
"# (clone may be $1 or $3, depending on leading -c auth args)\n" +
|
||||
"case \" $* \" in *\" clone \"*) d=$(eval \"echo \\${$#}\"); mkdir -p \"$d\" && printf 'fake-repo\\n' > \"$d/README.md\";; esac\n" +
|
||||
"exit 0\n"
|
||||
if err := os.WriteFile(filepath.Join(dir, "git"), []byte(script), 0o755); err != nil {
|
||||
t.Fatalf("write fake git: %v", err)
|
||||
@@ -345,7 +361,7 @@ func newTestSpawner(t *testing.T, f *fakeDocker) (*Spawner, *Store) {
|
||||
daemonToken = testToken
|
||||
store := openTestStore(t)
|
||||
hub := NewHub(store)
|
||||
sp, err := NewSpawner(store, hub, "https://gitlab.example/")
|
||||
sp, err := NewSpawner(context.Background(), store, hub, "https://gitlab.example/")
|
||||
if err != nil {
|
||||
t.Fatalf("NewSpawner: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user