daemon: integrate QoL slices 1-5 (model/rename/catalog, history deletes, stats, repo prepare+imageUsed+built) — 95.3% cover green
This commit is contained in:
@@ -83,7 +83,7 @@ func TestAPISpawnStatusAndContainerLifecycle(t *testing.T) {
|
||||
if err := json.Unmarshal([]byte(body), &res); err != nil {
|
||||
t.Fatalf("decode spawn result: %v", err)
|
||||
}
|
||||
if res.SessionID == "" || res.ContainerID != "" {
|
||||
if res.SessionID == "" || res.ImageUsed != imageRefWorker {
|
||||
t.Fatalf("spawn result = %+v", res)
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ func TestAPIWebHandlerEmbedded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAPIRepoImagesCRUD(t *testing.T) {
|
||||
ts, store := newTestServer(t)
|
||||
ts, _ := newSpawnAPIServer(t)
|
||||
auth := testToken
|
||||
|
||||
// auth required on the new namespace
|
||||
@@ -450,21 +450,23 @@ func TestAPIRepoImagesCRUD(t *testing.T) {
|
||||
if code != http.StatusOK || !strings.Contains(body, `"ok":true`) {
|
||||
t.Fatalf("put image = %d %s", code, body)
|
||||
}
|
||||
// a second repo, then listing is sorted by repo
|
||||
// a second repo, then listing is sorted by repo; built reflects the fake
|
||||
// docker store (legacy mode: only the default worker image exists)
|
||||
if code, _ := apiReq(t, http.MethodPut, ts.URL+"/api/repos/alpha/repo/image", auth, `{"image":"lvmh-worker-alpha:1.2.3"}`); code != http.StatusOK {
|
||||
t.Fatalf("put tagged image = %d", code)
|
||||
}
|
||||
code, body = apiReq(t, http.MethodGet, ts.URL+"/api/repos", auth, "")
|
||||
if code != http.StatusOK || body != `[{"repo":"alpha/repo","image":"lvmh-worker-alpha:1.2.3"},{"repo":"group/project","image":"lvmh-worker-group--project-ab12cd"}]`+"\n" {
|
||||
if code != http.StatusOK || body != `[{"repo":"alpha/repo","image":"lvmh-worker-alpha:1.2.3","built":false},{"repo":"group/project","image":"lvmh-worker-group--project-ab12cd","built":false}]`+"\n" {
|
||||
t.Fatalf("repos = %d %s", code, body)
|
||||
}
|
||||
|
||||
// upsert via PUT
|
||||
// upsert via PUT, verified through the listing
|
||||
if code, _ := apiReq(t, http.MethodPut, ts.URL+"/api/repos/group/project/image", auth, `{"image":"lvmh-worker-other"}`); code != http.StatusOK {
|
||||
t.Fatalf("upsert = %d", code)
|
||||
}
|
||||
if img, ok, _ := store.GetRepoImage("group/project"); !ok || img != "lvmh-worker-other" {
|
||||
t.Fatalf("after upsert = %q %v", img, ok)
|
||||
code, body = apiReq(t, http.MethodGet, ts.URL+"/api/repos", auth, "")
|
||||
if code != http.StatusOK || !strings.Contains(body, `{"repo":"group/project","image":"lvmh-worker-other","built":false}`) {
|
||||
t.Fatalf("after upsert = %d %s", code, body)
|
||||
}
|
||||
|
||||
// delete → gone; idempotent delete
|
||||
|
||||
Reference in New Issue
Block a user