fix tests
This commit is contained in:
parent
ec7e57d2f5
commit
6e630f9cd5
|
@ -26,6 +26,8 @@ type testSession struct {
|
|||
Router *mux.Router
|
||||
|
||||
AllowListDB *mockdb.FakeAllowListService
|
||||
PinnedDB *mockdb.FakePinnedNoticesService
|
||||
NoticeDB *mockdb.FakeNoticesService
|
||||
|
||||
RoomState *roomstate.Manager
|
||||
}
|
||||
|
@ -35,6 +37,8 @@ func newSession(t *testing.T) *testSession {
|
|||
|
||||
// fake dbs
|
||||
ts.AllowListDB = new(mockdb.FakeAllowListService)
|
||||
ts.PinnedDB = new(mockdb.FakePinnedNoticesService)
|
||||
ts.NoticeDB = new(mockdb.FakeNoticesService)
|
||||
|
||||
log, _ := logtest.KitLogger("admin", t)
|
||||
ctx := context.TODO()
|
||||
|
@ -70,7 +74,7 @@ func newSession(t *testing.T) *testSession {
|
|||
}
|
||||
|
||||
ts.Mux = http.NewServeMux()
|
||||
ts.Mux.Handle("/", Handler(r, ts.RoomState, ts.AllowListDB))
|
||||
ts.Mux.Handle("/", Handler(r, ts.RoomState, ts.AllowListDB, ts.NoticeDB, ts.PinnedDB))
|
||||
ts.Client = tester.New(ts.Mux, t)
|
||||
|
||||
return &ts
|
||||
|
|
|
@ -63,19 +63,6 @@ func TestNotFound(t *testing.T) {
|
|||
a.Equal("Error #404 - Not Found", found)
|
||||
}
|
||||
|
||||
func TestNewsRegisterd(t *testing.T) {
|
||||
ts := setup(t)
|
||||
|
||||
a := assert.New(t)
|
||||
|
||||
html, resp := ts.Client.GetHTML("/news/")
|
||||
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
||||
assertLocalized(t, html, []localizedElement{
|
||||
{"#welcome", "NewsWelcome"},
|
||||
{"title", "NewsTitle"},
|
||||
})
|
||||
}
|
||||
|
||||
func TestRestricted(t *testing.T) {
|
||||
ts := setup(t)
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ type testSession struct {
|
|||
AuthDB *mockdb.FakeAuthWithSSBService
|
||||
AuthFallbackDB *mockdb.FakeAuthFallbackService
|
||||
AllowListDB *mockdb.FakeAllowListService
|
||||
PinnedDB *mockdb.FakePinnedNoticesService
|
||||
NoticeDB *mockdb.FakeNoticesService
|
||||
|
||||
RoomState *roomstate.Manager
|
||||
}
|
||||
|
@ -56,6 +58,8 @@ func setup(t *testing.T) *testSession {
|
|||
ts.AuthDB = new(mockdb.FakeAuthWithSSBService)
|
||||
ts.AuthFallbackDB = new(mockdb.FakeAuthFallbackService)
|
||||
ts.AllowListDB = new(mockdb.FakeAllowListService)
|
||||
ts.PinnedDB = new(mockdb.FakePinnedNoticesService)
|
||||
ts.NoticeDB = new(mockdb.FakeNoticesService)
|
||||
|
||||
log, _ := logtest.KitLogger("complete", t)
|
||||
ctx := context.TODO()
|
||||
|
@ -70,6 +74,8 @@ func setup(t *testing.T) *testSession {
|
|||
ts.AuthDB,
|
||||
ts.AuthFallbackDB,
|
||||
ts.AllowListDB,
|
||||
ts.NoticeDB,
|
||||
ts.PinnedDB,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal("setup: handler init failed:", err)
|
||||
|
|
Loading…
Reference in New Issue