mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 13:22:26 +03:00
Preparations for removing BaseDendrite
(#3016)
Preparations to actually remove/replace `BaseDendrite`. Quite a few changes: - SyncAPI accepts an `fulltext.Indexer` interface (fulltext is removed from `BaseDendrite`) - Caches are removed from `BaseDendrite` - Introduces a `Router` struct (likely to change) - also fixes #2903 - Introduces a `sqlutil.ConnectionManager`, which should remove `base.DatabaseConnection` later on - probably more
This commit is contained in:
parent
d88f71ab71
commit
5579121c6f
85 changed files with 722 additions and 470 deletions
38
internal/httputil/routing_test.go
Normal file
38
internal/httputil/routing_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package httputil
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRoutersError(t *testing.T) {
|
||||
r := NewRouters()
|
||||
|
||||
// not found test
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, filepath.Join(PublicFederationPathPrefix, "doesnotexist"), nil)
|
||||
r.Federation.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusNotFound {
|
||||
t.Fatalf("unexpected status code: %d - %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
if ct := rec.Header().Get("Content-Type"); ct != "application/json" {
|
||||
t.Fatalf("unexpected content-type: %s", ct)
|
||||
}
|
||||
|
||||
// not allowed test
|
||||
r.DendriteAdmin.
|
||||
Handle("/test", http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {})).
|
||||
Methods(http.MethodPost)
|
||||
|
||||
rec = httptest.NewRecorder()
|
||||
req = httptest.NewRequest(http.MethodGet, filepath.Join(DendriteAdminPathPrefix, "test"), nil)
|
||||
r.DendriteAdmin.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusMethodNotAllowed {
|
||||
t.Fatalf("unexpected status code: %d - %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
if ct := rec.Header().Get("Content-Type"); ct != "application/json" {
|
||||
t.Fatalf("unexpected content-type: %s", ct)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue