update_apply_test.go 865 B

1234567891011121314151617181920212223242526272829303132
  1. // update_apply_test.go — regresión del gate de apply (layout estable).
  2. package httpapi_test
  3. import (
  4. "encoding/json"
  5. "net/http"
  6. "testing"
  7. )
  8. func TestApplyUnavailableOnStableLayout(t *testing.T) {
  9. // Sin deploy/update.sh → modo estable: POST /api/update/apply → 409.
  10. root := t.TempDir()
  11. ts := makeTestServerWithUpdater(t, root)
  12. cookie := adminCookie(t, ts)
  13. req, _ := http.NewRequest("POST", ts.URL+"/api/update/apply", nil)
  14. req.Header.Set("Cookie", "session="+cookie)
  15. res, err := http.DefaultClient.Do(req)
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. defer res.Body.Close()
  20. if res.StatusCode != 409 {
  21. t.Fatalf("apply estable: got %d want 409", res.StatusCode)
  22. }
  23. var body map[string]any
  24. if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
  25. t.Fatal(err)
  26. }
  27. if body["error"] != "update_unavailable" {
  28. t.Errorf("error: %+v", body)
  29. }
  30. }