mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 08:55:28 +08:00
36 lines
787 B
Go
36 lines
787 B
Go
package accounts
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"ds2api/internal/account"
|
|
"ds2api/internal/config"
|
|
adminshared "ds2api/internal/httpapi/admin/shared"
|
|
)
|
|
|
|
func newHTTPAdminHarness(t *testing.T, rawConfig string, ds adminshared.DeepSeekCaller) http.Handler {
|
|
t.Helper()
|
|
t.Setenv("DS2API_CONFIG_JSON", rawConfig)
|
|
store := config.LoadStore()
|
|
h := &Handler{
|
|
Store: store,
|
|
Pool: account.NewPool(store),
|
|
DS: ds,
|
|
}
|
|
r := chi.NewRouter()
|
|
RegisterRoutes(r, h)
|
|
return r
|
|
}
|
|
|
|
func adminReq(method, path string, body []byte) *http.Request {
|
|
req := httptest.NewRequest(method, path, bytes.NewReader(body))
|
|
req.Header.Set("Authorization", "Bearer admin")
|
|
req.Header.Set("Content-Type", "application/json")
|
|
return req
|
|
}
|