summaryrefslogtreecommitdiff
path: root/internal/cache/status_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-02 10:58:42 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-02 11:58:42 +0200
commit077e66381fffb47038a99ce82c7c07a1f1b19f62 (patch)
tree69680266fae036a7da476ead8d45a37ebdb7d9c5 /internal/cache/status_test.go
parent[performance] use GetAccountByUsernameDomain() for local account lookups to r... (diff)
downloadgotosocial-077e66381fffb47038a99ce82c7c07a1f1b19f62.tar.xz
[performance] cache account db lookups by public key URI (#795)
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/cache/status_test.go')
-rw-r--r--internal/cache/status_test.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/cache/status_test.go b/internal/cache/status_test.go
index 8b0621182..c1c4173fb 100644
--- a/internal/cache/status_test.go
+++ b/internal/cache/status_test.go
@@ -19,6 +19,7 @@
package cache_test
import (
+ "fmt"
"testing"
"github.com/stretchr/testify/suite"
@@ -59,15 +60,15 @@ func (suite *StatusCacheTestSuite) TestStatusCache() {
// Check we can retrieve
check, ok = suite.cache.GetByID(status.ID)
if !ok && !statusIs(status, check) {
- suite.Fail("Failed to fetch expected account with ID: %s", status.ID)
+ suite.Fail(fmt.Sprintf("Failed to fetch expected account with ID: %s", status.ID))
}
check, ok = suite.cache.GetByURI(status.URI)
if status.URI != "" && !ok && !statusIs(status, check) {
- suite.Fail("Failed to fetch expected account with URI: %s", status.URI)
+ suite.Fail(fmt.Sprintf("Failed to fetch expected account with URI: %s", status.URI))
}
check, ok = suite.cache.GetByURL(status.URL)
if status.URL != "" && !ok && !statusIs(status, check) {
- suite.Fail("Failed to fetch expected account with URL: %s", status.URL)
+ suite.Fail(fmt.Sprintf("Failed to fetch expected account with URL: %s", status.URL))
}
}
}
@@ -103,5 +104,10 @@ func TestStatusCache(t *testing.T) {
}
func statusIs(status1, status2 *gtsmodel.Status) bool {
- return status1.ID == status2.ID && status1.URI == status2.URI && status1.URL == status2.URL
+ if status1 == nil || status2 == nil {
+ return status1 == status2
+ }
+ return status1.ID == status2.ID &&
+ status1.URI == status2.URI &&
+ status1.URL == status2.URL
}