update to use roomdb instead of admindb

This commit is contained in:
cblgh 2021-03-11 14:50:38 +01:00
parent ba2fbbef8e
commit cc17f97077
2 changed files with 14 additions and 9 deletions

View File

@ -7,11 +7,16 @@ import (
"strings"
"testing"
"github.com/ssb-ngi-pointer/go-ssb-room/admindb"
"github.com/ssb-ngi-pointer/go-ssb-room/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/web"
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
"github.com/stretchr/testify/assert"
)
/* TODO:
* add a new test that makes sure that /translation/add only accepts POST
* add a check inside the handler proper
*/
func TestNoticeAddLanguageIncludesAllFields(t *testing.T) {
ts := newSession(t)
@ -20,7 +25,7 @@ func TestNoticeAddLanguageIncludesAllFields(t *testing.T) {
urlTo := web.NewURLTo(ts.Router)
// to test translations we first need to add a notice to the notice mockdb
notice := admindb.Notice{
notice := roomdb.Notice{
ID: 1,
Title: "News",
Content: "Breaking News: This Room Has News",
@ -31,7 +36,7 @@ func TestNoticeAddLanguageIncludesAllFields(t *testing.T) {
ts.PinnedDB.GetReturns(&notice, nil)
/* TODO: are you only supposed to add translations to pinned notices? */
u := urlTo(router.AdminNoticeDraftTranslation, "name", admindb.NoticeNews.String())
u := urlTo(router.AdminNoticeDraftTranslation, "name", roomdb.NoticeNews.String())
html, resp := ts.Client.GetHTML(u.String())
a.Equal(http.StatusOK, resp.Code)
fmt.Println(html.Html())
@ -65,7 +70,7 @@ func TestNoticeEditFormIncludesAllFields(t *testing.T) {
}
// Create mock notice data to operate on
notice := admindb.Notice{
notice := roomdb.Notice{
ID: 1,
Title: "News",
Content: "Breaking News: This Room Has News",

View File

@ -6,7 +6,7 @@ import (
"net/url"
"testing"
"github.com/ssb-ngi-pointer/go-ssb-room/admindb"
"github.com/ssb-ngi-pointer/go-ssb-room/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/web"
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
"github.com/stretchr/testify/assert"
@ -18,7 +18,7 @@ func TestNoticeSmokeTest(t *testing.T) {
ts := setup(t)
a := assert.New(t)
noticeData := admindb.Notice{
noticeData := roomdb.Notice{
ID: 1,
Title: "Welcome!",
}
@ -39,7 +39,7 @@ Hello world!
## The loveliest of rooms is here
`
noticeData := admindb.Notice{
noticeData := roomdb.Notice{
ID: 1,
Title: "Welcome!",
Content: markdown,
@ -61,7 +61,7 @@ func TestNoticesEditButtonVisible(t *testing.T) {
urlTo := web.NewURLTo(ts.Router)
noticeData := admindb.Notice{
noticeData := roomdb.Notice{
ID: 42,
Title: "Welcome!",
Content: `super simple conent`,
@ -118,7 +118,7 @@ func TestNoticesEditButtonVisible(t *testing.T) {
}
// have the database return okay for any user
testUser := &admindb.User{
testUser := &roomdb.User{
ID: 23,
Name: "test admin",
}