Loading internal/api/handlers_user.go +3 −1 Changes for internal/api/handlers_user.go: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -683,7 +683,9 @@ func (a *API) handlePatchServer(w http.ResponseWriter, r *http.Request) { // the SAME helpers the create form uses. `changed` records what actually moves // so the response and audit name the real mutation. var patch ServerSpecPatch var changed []string // Non-nil so a patch that moves nothing (re-picking the image a server is // already pinned to) still answers "patched": [], as the API documents. changed := []string{} // imageFrom is the image a confirmed image change replaced, for the audit row. var imageFrom string Loading internal/api/images_pin_test.go +4 −0 Changes for internal/api/images_pin_test.go: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/http" "strings" "testing" "felis.lolicon.best/internal/imagepin" Loading Loading @@ -136,6 +137,9 @@ func TestPatchServerImageSamePinIsNoChange(t *testing.T) { if p := cl.patched["survival"]; p.Image != nil { t.Errorf("patched image = %q, want no image change", *p.Image) } if !strings.Contains(w.Body.String(), `"patched":[]`) { t.Errorf("body = %s, want an empty patched list", w.Body.String()) } if len(repo.audits) != 1 || repo.audits[0].Payload != nil { t.Errorf("audits = %+v, want a plain server.patch", repo.audits) } Loading Loading
internal/api/handlers_user.go +3 −1 Changes for internal/api/handlers_user.go: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -683,7 +683,9 @@ func (a *API) handlePatchServer(w http.ResponseWriter, r *http.Request) { // the SAME helpers the create form uses. `changed` records what actually moves // so the response and audit name the real mutation. var patch ServerSpecPatch var changed []string // Non-nil so a patch that moves nothing (re-picking the image a server is // already pinned to) still answers "patched": [], as the API documents. changed := []string{} // imageFrom is the image a confirmed image change replaced, for the audit row. var imageFrom string Loading
internal/api/images_pin_test.go +4 −0 Changes for internal/api/images_pin_test.go: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/http" "strings" "testing" "felis.lolicon.best/internal/imagepin" Loading Loading @@ -136,6 +137,9 @@ func TestPatchServerImageSamePinIsNoChange(t *testing.T) { if p := cl.patched["survival"]; p.Image != nil { t.Errorf("patched image = %q, want no image change", *p.Image) } if !strings.Contains(w.Body.String(), `"patched":[]`) { t.Errorf("body = %s, want an empty patched list", w.Body.String()) } if len(repo.audits) != 1 || repo.audits[0].Payload != nil { t.Errorf("audits = %+v, want a plain server.patch", repo.audits) } Loading