From 4fe63ccaecf8e2e96f6ca2d3a2cb49d6db2c3cf4 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 23 Oct 2023 16:59:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Remove=20CountUser=20fu?= =?UTF-8?q?nction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/storage/mock_Storage.go | 24 ------------------------ internal/storage/sql_storage.go | 7 ------- internal/storage/sql_storage_test.go | 10 ---------- internal/storage/storage.go | 1 - 4 files changed, 42 deletions(-) diff --git a/internal/storage/mock_Storage.go b/internal/storage/mock_Storage.go index 810055c5..f137410c 100644 --- a/internal/storage/mock_Storage.go +++ b/internal/storage/mock_Storage.go @@ -27,30 +27,6 @@ func (_m *MockStorage) AddTickerUser(ticker *Ticker, user *User) error { return r0 } -// CountUser provides a mock function with given fields: -func (_m *MockStorage) CountUser() (int, error) { - ret := _m.Called() - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func() (int, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // DeleteAttachmentsByMessage provides a mock function with given fields: message func (_m *MockStorage) DeleteAttachmentsByMessage(message Message) error { ret := _m.Called(message) diff --git a/internal/storage/sql_storage.go b/internal/storage/sql_storage.go index 8e303ca1..8edfafb5 100644 --- a/internal/storage/sql_storage.go +++ b/internal/storage/sql_storage.go @@ -21,13 +21,6 @@ func NewSqlStorage(db *gorm.DB, uploadPath string) *SqlStorage { } } -func (s *SqlStorage) CountUser() (int, error) { - var count int64 - err := s.DB.Model(&User{}).Count(&count).Error - - return int(count), err -} - func (s *SqlStorage) FindUsers() ([]User, error) { users := make([]User, 0) err := s.DB.Find(&users).Error diff --git a/internal/storage/sql_storage_test.go b/internal/storage/sql_storage_test.go index c069cfee..4fccc8e1 100644 --- a/internal/storage/sql_storage_test.go +++ b/internal/storage/sql_storage_test.go @@ -46,16 +46,6 @@ var _ = Describe("SqlStorage", func() { db.Exec("DELETE FROM uploads") }) - Describe("CountUser", func() { - It("returns the number of users", func() { - Expect(store.CountUser()).To(Equal(0)) - - err := db.Create(&User{}).Error - Expect(err).ToNot(HaveOccurred()) - Expect(store.CountUser()).To(Equal(1)) - }) - }) - Describe("FindUsers", func() { It("returns all users", func() { users, err := store.FindUsers() diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 5670562e..caadc56d 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -9,7 +9,6 @@ import ( var log = logrus.WithField("package", "storage") type Storage interface { - CountUser() (int, error) FindUsers() ([]User, error) FindUserByID(id int) (User, error) FindUsersByIDs(ids []int) ([]User, error)