summaryrefslogtreecommitdiff
path: root/internal/db/bundb/domain_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-02 11:17:46 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-02 12:17:46 +0200
commitd68c04a6c0964d795a8d475c2f73d201bc72e68b (patch)
tree415746fa7279c4776ee822f1513f45c28a22e547 /internal/db/bundb/domain_test.go
parent[feature] Federate custom emoji (outbound) (#791) (diff)
downloadgotosocial-d68c04a6c0964d795a8d475c2f73d201bc72e68b.tar.xz
[performance] cache recently allowed/denied domains to cut down on db calls (#794)
* fetch creation and fetching domain blocks from db Signed-off-by: kim <grufwub@gmail.com> * add separate domainblock cache type, handle removing block from cache on delete Signed-off-by: kim <grufwub@gmail.com> * fix sentinel nil values being passed into cache Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/db/bundb/domain_test.go')
-rw-r--r--internal/db/bundb/domain_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/db/bundb/domain_test.go b/internal/db/bundb/domain_test.go
index 1a3fed24d..b326236ad 100644
--- a/internal/db/bundb/domain_test.go
+++ b/internal/db/bundb/domain_test.go
@@ -21,6 +21,7 @@ package bundb_test
import (
"context"
"testing"
+ "time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
@@ -33,10 +34,15 @@ type DomainTestSuite struct {
func (suite *DomainTestSuite) TestIsDomainBlocked() {
ctx := context.Background()
+ now := time.Now()
+
domainBlock := &gtsmodel.DomainBlock{
ID: "01G204214Y9TNJEBX39C7G88SW",
Domain: "some.bad.apples",
+ CreatedAt: now,
+ UpdatedAt: now,
CreatedByAccountID: suite.testAccounts["admin_account"].ID,
+ CreatedByAccount: suite.testAccounts["admin_account"],
}
// no domain block exists for the given domain yet
@@ -44,7 +50,8 @@ func (suite *DomainTestSuite) TestIsDomainBlocked() {
suite.NoError(err)
suite.False(blocked)
- suite.db.Put(ctx, domainBlock)
+ err = suite.db.CreateDomainBlock(ctx, *domainBlock)
+ suite.NoError(err)
// domain block now exists
blocked, err = suite.db.IsDomainBlocked(ctx, domainBlock.Domain)