summaryrefslogtreecommitdiff
path: root/testrig
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-04-20 18:14:23 +0200
committerLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-04-20 18:14:23 +0200
commitdafc3b5b92865b97be48456e02ad235f4c79cf4e (patch)
tree0f97edf4377f406df321054d26e731ff5dcc6667 /testrig
parentApi/v1/statuses (#11) (diff)
downloadgotosocial-dafc3b5b92865b97be48456e02ad235f4c79cf4e.tar.xz
linting + organizing
Diffstat (limited to 'testrig')
-rw-r--r--testrig/distributor.go1
-rw-r--r--testrig/mediahandler.go2
-rw-r--r--testrig/router.go1
-rw-r--r--testrig/storage.go12
-rw-r--r--testrig/testmodels.go34
5 files changed, 26 insertions, 24 deletions
diff --git a/testrig/distributor.go b/testrig/distributor.go
index e21321d53..a7206e5ea 100644
--- a/testrig/distributor.go
+++ b/testrig/distributor.go
@@ -20,6 +20,7 @@ package testrig
import "github.com/superseriousbusiness/gotosocial/internal/distributor"
+// NewTestDistributor returns a Distributor suitable for testing purposes
func NewTestDistributor() distributor.Distributor {
return distributor.New(NewTestLog())
}
diff --git a/testrig/mediahandler.go b/testrig/mediahandler.go
index fd7986689..ef6901032 100644
--- a/testrig/mediahandler.go
+++ b/testrig/mediahandler.go
@@ -26,6 +26,6 @@ import (
// NewTestMediaHandler returns a media handler with the default test config, the default test logger,
// and the given db and storage.
-func NewTestMediaHandler(db db.DB, storage storage.Storage) media.MediaHandler {
+func NewTestMediaHandler(db db.DB, storage storage.Storage) media.Handler {
return media.New(NewTestConfig(), db, storage, NewTestLog())
}
diff --git a/testrig/router.go b/testrig/router.go
index abd168724..83ce7b602 100644
--- a/testrig/router.go
+++ b/testrig/router.go
@@ -20,6 +20,7 @@ package testrig
import "github.com/superseriousbusiness/gotosocial/internal/router"
+// NewTestRouter returns a Router suitable for testing
func NewTestRouter() router.Router {
r, err := router.New(NewTestConfig(), NewTestLog())
if err != nil {
diff --git a/testrig/storage.go b/testrig/storage.go
index 3b520364b..28484b2e3 100644
--- a/testrig/storage.go
+++ b/testrig/storage.go
@@ -36,15 +36,15 @@ func NewTestStorage() storage.Storage {
// StandardStorageSetup populates the storage with standard test entries from the given directory.
func StandardStorageSetup(s storage.Storage, relativePath string) {
- storedA := NewTestStoredAttachments()
+ storedA := newTestStoredAttachments()
a := NewTestAttachments()
for k, paths := range storedA {
attachmentInfo, ok := a[k]
if !ok {
panic(fmt.Errorf("key %s not found in test attachments", k))
}
- filenameOriginal := paths.original
- filenameSmall := paths.small
+ filenameOriginal := paths.Original
+ filenameSmall := paths.Small
pathOriginal := attachmentInfo.File.Path
pathSmall := attachmentInfo.Thumbnail.Path
bOriginal, err := os.ReadFile(fmt.Sprintf("%s/%s", relativePath, filenameOriginal))
@@ -63,15 +63,15 @@ func StandardStorageSetup(s storage.Storage, relativePath string) {
}
}
- storedE := NewTestStoredEmoji()
+ storedE := newTestStoredEmoji()
e := NewTestEmojis()
for k, paths := range storedE {
emojiInfo, ok := e[k]
if !ok {
panic(fmt.Errorf("key %s not found in test emojis", k))
}
- filenameOriginal := paths.original
- filenameStatic := paths.static
+ filenameOriginal := paths.Original
+ filenameStatic := paths.Static
pathOriginal := emojiInfo.ImagePath
pathStatic := emojiInfo.ImageStaticPath
bOriginal, err := os.ReadFile(fmt.Sprintf("%s/%s", relativePath, filenameOriginal))
diff --git a/testrig/testmodels.go b/testrig/testmodels.go
index f028bbd8d..0d95ef21d 100644
--- a/testrig/testmodels.go
+++ b/testrig/testmodels.go
@@ -700,39 +700,39 @@ func NewTestEmojis() map[string]*gtsmodel.Emoji {
}
type filenames struct {
- original string
- small string
- static string
+ Original string
+ Small string
+ Static string
}
-// NewTestStoredAttachments returns a map of filenames, keyed according to which attachment they pertain to.
-func NewTestStoredAttachments() map[string]filenames {
+// newTestStoredAttachments returns a map of filenames, keyed according to which attachment they pertain to.
+func newTestStoredAttachments() map[string]filenames {
return map[string]filenames{
"admin_account_status_1_attachment_1": {
- original: "welcome-original.jpeg",
- small: "welcome-small.jpeg",
+ Original: "welcome-original.jpeg",
+ Small: "welcome-small.jpeg",
},
"local_account_1_status_4_attachment_1": {
- original: "trent-original.gif",
- small: "trent-small.jpeg",
+ Original: "trent-original.gif",
+ Small: "trent-small.jpeg",
},
"local_account_1_unattached_1": {
- original: "ohyou-original.jpeg",
- small: "ohyou-small.jpeg",
+ Original: "ohyou-original.jpeg",
+ Small: "ohyou-small.jpeg",
},
"local_account_1_avatar": {
- original: "zork-original.jpeg",
- small: "zork-small.jpeg",
+ Original: "zork-original.jpeg",
+ Small: "zork-small.jpeg",
},
}
}
-// NewtestStoredEmoji returns a map of filenames, keyed according to which emoji they pertain to
-func NewTestStoredEmoji() map[string]filenames {
+// newTestStoredEmoji returns a map of filenames, keyed according to which emoji they pertain to
+func newTestStoredEmoji() map[string]filenames {
return map[string]filenames{
"rainbow": {
- original: "rainbow-original.png",
- static: "rainbow-static.png",
+ Original: "rainbow-original.png",
+ Static: "rainbow-static.png",
},
}
}