aboutsummaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-06 23:53:55 +0800
committerGitHub <noreply@github.com>2020-04-06 23:53:55 +0800
commit2b3655fa118abaa33a0e064233fdc8c670487c62 (patch)
treec160e5aaa886e920f4cef8bd2bb29a002e6399fe /internal/db
parentca2f7a7e1610fd8e99649dc1ed2058c2f362c57d (diff)
lfs: add tests to batch endpoint (#6073)
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/mocks.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/db/mocks.go b/internal/db/mocks.go
index 0a52042b..b81dab13 100644
--- a/internal/db/mocks.go
+++ b/internal/db/mocks.go
@@ -5,7 +5,10 @@
package db
import (
+ "io"
"testing"
+
+ "gogs.io/gogs/internal/lfsutil"
)
// NOTE: Mocks are sorted in alphabetical order.
@@ -33,6 +36,34 @@ func SetMockAccessTokensStore(t *testing.T, mock AccessTokensStore) {
})
}
+var _ LFSStore = (*MockLFSStore)(nil)
+
+type MockLFSStore struct {
+ MockCreateObject func(repoID int64, oid lfsutil.OID, rc io.ReadCloser, storage lfsutil.Storage) error
+ MockGetObjectByOID func(repoID int64, oid lfsutil.OID) (*LFSObject, error)
+ MockGetObjectsByOIDs func(repoID int64, oids ...lfsutil.OID) ([]*LFSObject, error)
+}
+
+func (m *MockLFSStore) CreateObject(repoID int64, oid lfsutil.OID, rc io.ReadCloser, storage lfsutil.Storage) error {
+ return m.MockCreateObject(repoID, oid, rc, storage)
+}
+
+func (m *MockLFSStore) GetObjectByOID(repoID int64, oid lfsutil.OID) (*LFSObject, error) {
+ return m.MockGetObjectByOID(repoID, oid)
+}
+
+func (m *MockLFSStore) GetObjectsByOIDs(repoID int64, oids ...lfsutil.OID) ([]*LFSObject, error) {
+ return m.MockGetObjectsByOIDs(repoID, oids...)
+}
+
+func SetMockLFSStore(t *testing.T, mock LFSStore) {
+ before := LFS
+ LFS = mock
+ t.Cleanup(func() {
+ LFS = before
+ })
+}
+
var _ PermsStore = (*MockPermsStore)(nil)
type MockPermsStore struct {