push a bit of progress while fixing the tests
This commit is contained in:
parent
5404b6fdbe
commit
3cff453494
|
@ -1,20 +1,31 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import qgen "github.com/Azareal/Gosora/query_gen"
|
import (
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
qgen "github.com/Azareal/Gosora/query_gen"
|
||||||
|
)
|
||||||
|
|
||||||
type BlockStore interface {
|
type BlockStore interface {
|
||||||
IsBlockedBy(blocker int, blockee int) (bool, error)
|
IsBlockedBy(blocker int, blockee int) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DefaultBlockStore struct {
|
type DefaultBlockStore struct {
|
||||||
|
isBlocked *sql.Stmt
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultBlockStore(acc *qgen.Accumulator) (*DefaultBlockStore, error) {
|
func NewDefaultBlockStore(acc *qgen.Accumulator) (*DefaultBlockStore, error) {
|
||||||
return &DefaultBlockStore{}, acc.FirstError()
|
return &DefaultBlockStore{
|
||||||
|
isBlocked: acc.Select("users_blocks").Cols("blocker").Where("blocker = ? AND blockedUser = ?").Prepare(),
|
||||||
|
}, acc.FirstError()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefaultBlockStore) IsBlockedBy(blocker int, blockee int) (bool, error) {
|
func (s *DefaultBlockStore) IsBlockedBy(blocker int, blockee int) (bool, error) {
|
||||||
return false, nil
|
err := s.isBlocked.QueryRow(blocker, blockee).Scan(&blocker)
|
||||||
|
if err != nil && err != ErrNoRows {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return err != ErrNoRows, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type FriendStore interface {
|
type FriendStore interface {
|
||||||
|
|
|
@ -287,6 +287,9 @@ func TestParser(t *testing.T) {
|
||||||
l.Add("@0", "<red>[Invalid Profile]</red>")
|
l.Add("@0", "<red>[Invalid Profile]</red>")
|
||||||
l.Add("@-1", "<red>[Invalid Profile]</red>1")
|
l.Add("@-1", "<red>[Invalid Profile]</red>1")
|
||||||
|
|
||||||
|
// TODO: Fix this hack and make the results a bit more reproducible, push the tests further in the process.
|
||||||
|
pre2 := c.Site.EnableSsl
|
||||||
|
c.Site.EnableSsl = true
|
||||||
for _, item := range l.Items {
|
for _, item := range l.Items {
|
||||||
if res := c.ParseMessage(item.Msg, 1, "forums"); res != item.Expects {
|
if res := c.ParseMessage(item.Msg, 1, "forums"); res != item.Expects {
|
||||||
if item.Name != "" {
|
if item.Name != "" {
|
||||||
|
@ -298,10 +301,11 @@ func TestParser(t *testing.T) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.Site.EnableSsl = pre2
|
||||||
|
|
||||||
l = &METriList{nil}
|
l = &METriList{nil}
|
||||||
pre := c.Site.URL // Just in case this is localhost...
|
pre := c.Site.URL // Just in case this is localhost...
|
||||||
pre2 := c.Site.EnableSsl
|
pre2 = c.Site.EnableSsl
|
||||||
c.Site.URL = "example.com"
|
c.Site.URL = "example.com"
|
||||||
c.Site.EnableSsl = true
|
c.Site.EnableSsl = true
|
||||||
l.Add("//"+c.Site.URL, "<a href='https://"+c.Site.URL+"'>"+c.Site.URL+"</a>")
|
l.Add("//"+c.Site.URL, "<a href='https://"+c.Site.URL+"'>"+c.Site.URL+"</a>")
|
||||||
|
|
Loading…
Reference in New Issue