| 68 | } |
| 69 | |
| 70 | func TestHealthEndpoint(t *testing.T) { |
| 71 | server, _, _ := setupAPI(t) |
| 72 | resp, err := http.Get(server.URL + "/api/health") |
| 73 | if err != nil { |
| 74 | t.Fatal(err) |
| 75 | } |
| 76 | defer resp.Body.Close() |
| 77 | |
| 78 | if resp.StatusCode != 200 { |
| 79 | t.Errorf("status = %d, want 200", resp.StatusCode) |
| 80 | } |
| 81 | var body map[string]string |
| 82 | json.NewDecoder(resp.Body).Decode(&body) |
| 83 | if body["status"] != "ok" { |
| 84 | t.Errorf("status = %q, want ok", body["status"]) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | func setupAPIWithSMTP(t *testing.T) (*httptest.Server, *identity.Store, *pgxpool.Pool, func() []testutil.SMTPMessage) { |
| 89 | t.Helper() |