Download this file
| 1 | package instancectl |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | "net/http/httptest" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // Root's writers-stopped observation (claim Plan 11, R3) is served by the |
| 10 | // claim handler, like the stop it precedes. |
| 11 | func TestClaimWritersStoppedRoutesToTheClaimHandler(t *testing.T) { |
| 12 | var got string |
| 13 | s := &Server{ClaimStop: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { got = r.URL.Path })} |
| 14 | rec := httptest.NewRecorder() |
| 15 | s.Handler().ServeHTTP(rec, httptest.NewRequest(http.MethodPost, "/claim/writers-stopped", nil)) |
| 16 | if got != "/claim/writers-stopped" { |
| 17 | t.Fatalf("the claim handler did not see the request: %q (status %d)", got, rec.Code) |
| 18 | } |
| 19 | } |
| 20 | |