forked from mtusi2026/mtusi2026lab3
feat: API replicas over HAProxy (3)
This commit is contained in:
@@ -57,7 +57,7 @@ func newStack(t *testing.T, dbURL, redisURL string, ttl time.Duration) *httptest
|
||||
chats := service.NewChatService(store)
|
||||
messages := service.NewMessageService(chats, store)
|
||||
h := handler.New(users, auth, chats, messages, []handler.Pinger{store.Ping, sessions.Ping}, slog.New(slog.DiscardHandler))
|
||||
srv := httptest.NewServer(router.New(h))
|
||||
srv := httptest.NewServer(router.New(h, "test"))
|
||||
t.Cleanup(srv.Close)
|
||||
return srv
|
||||
}
|
||||
@@ -81,6 +81,9 @@ func request(t *testing.T, srv *httptest.Server, method, path, token, body strin
|
||||
if token != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
}
|
||||
if method == http.MethodPost && strings.HasSuffix(path, "/messages") {
|
||||
req.Header.Set("Idempotency-Key", uuid.New().String())
|
||||
}
|
||||
resp, err := srv.Client().Do(req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user