github.com/demisto/mattermost-server@v4.9.0-rc3+incompatible/store/storetest/store.go (about)

     1  // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package storetest
     5  
     6  import (
     7  	"github.com/stretchr/testify/mock"
     8  
     9  	"github.com/mattermost/mattermost-server/store"
    10  	"github.com/mattermost/mattermost-server/store/storetest/mocks"
    11  )
    12  
    13  // NewStoreChannel returns a channel that will receive the given result.
    14  func NewStoreChannel(result store.StoreResult) store.StoreChannel {
    15  	ch := make(store.StoreChannel, 1)
    16  	ch <- result
    17  	return ch
    18  }
    19  
    20  // Store can be used to provide mock stores for testing.
    21  type Store struct {
    22  	TeamStore                 mocks.TeamStore
    23  	ChannelStore              mocks.ChannelStore
    24  	PostStore                 mocks.PostStore
    25  	UserStore                 mocks.UserStore
    26  	AuditStore                mocks.AuditStore
    27  	ClusterDiscoveryStore     mocks.ClusterDiscoveryStore
    28  	ComplianceStore           mocks.ComplianceStore
    29  	SessionStore              mocks.SessionStore
    30  	OAuthStore                mocks.OAuthStore
    31  	SystemStore               mocks.SystemStore
    32  	WebhookStore              mocks.WebhookStore
    33  	CommandStore              mocks.CommandStore
    34  	CommandWebhookStore       mocks.CommandWebhookStore
    35  	PreferenceStore           mocks.PreferenceStore
    36  	LicenseStore              mocks.LicenseStore
    37  	TokenStore                mocks.TokenStore
    38  	EmojiStore                mocks.EmojiStore
    39  	StatusStore               mocks.StatusStore
    40  	FileInfoStore             mocks.FileInfoStore
    41  	ReactionStore             mocks.ReactionStore
    42  	JobStore                  mocks.JobStore
    43  	UserAccessTokenStore      mocks.UserAccessTokenStore
    44  	PluginStore               mocks.PluginStore
    45  	ChannelMemberHistoryStore mocks.ChannelMemberHistoryStore
    46  	RoleStore                 mocks.RoleStore
    47  }
    48  
    49  func (s *Store) Team() store.TeamStore                         { return &s.TeamStore }
    50  func (s *Store) Channel() store.ChannelStore                   { return &s.ChannelStore }
    51  func (s *Store) Post() store.PostStore                         { return &s.PostStore }
    52  func (s *Store) User() store.UserStore                         { return &s.UserStore }
    53  func (s *Store) Audit() store.AuditStore                       { return &s.AuditStore }
    54  func (s *Store) ClusterDiscovery() store.ClusterDiscoveryStore { return &s.ClusterDiscoveryStore }
    55  func (s *Store) Compliance() store.ComplianceStore             { return &s.ComplianceStore }
    56  func (s *Store) Session() store.SessionStore                   { return &s.SessionStore }
    57  func (s *Store) OAuth() store.OAuthStore                       { return &s.OAuthStore }
    58  func (s *Store) System() store.SystemStore                     { return &s.SystemStore }
    59  func (s *Store) Webhook() store.WebhookStore                   { return &s.WebhookStore }
    60  func (s *Store) Command() store.CommandStore                   { return &s.CommandStore }
    61  func (s *Store) CommandWebhook() store.CommandWebhookStore     { return &s.CommandWebhookStore }
    62  func (s *Store) Preference() store.PreferenceStore             { return &s.PreferenceStore }
    63  func (s *Store) License() store.LicenseStore                   { return &s.LicenseStore }
    64  func (s *Store) Token() store.TokenStore                       { return &s.TokenStore }
    65  func (s *Store) Emoji() store.EmojiStore                       { return &s.EmojiStore }
    66  func (s *Store) Status() store.StatusStore                     { return &s.StatusStore }
    67  func (s *Store) FileInfo() store.FileInfoStore                 { return &s.FileInfoStore }
    68  func (s *Store) Reaction() store.ReactionStore                 { return &s.ReactionStore }
    69  func (s *Store) Job() store.JobStore                           { return &s.JobStore }
    70  func (s *Store) UserAccessToken() store.UserAccessTokenStore   { return &s.UserAccessTokenStore }
    71  func (s *Store) Plugin() store.PluginStore                     { return &s.PluginStore }
    72  func (s *Store) Role() store.RoleStore                         { return &s.RoleStore }
    73  func (s *Store) ChannelMemberHistory() store.ChannelMemberHistoryStore {
    74  	return &s.ChannelMemberHistoryStore
    75  }
    76  func (s *Store) MarkSystemRanUnitTests()       { /* do nothing */ }
    77  func (s *Store) Close()                        { /* do nothing */ }
    78  func (s *Store) DropAllTables()                { /* do nothing */ }
    79  func (s *Store) TotalMasterDbConnections() int { return 1 }
    80  func (s *Store) TotalReadDbConnections() int   { return 1 }
    81  func (s *Store) TotalSearchDbConnections() int { return 1 }
    82  
    83  func (s *Store) AssertExpectations(t mock.TestingT) bool {
    84  	return mock.AssertExpectationsForObjects(t,
    85  		&s.TeamStore,
    86  		&s.ChannelStore,
    87  		&s.PostStore,
    88  		&s.UserStore,
    89  		&s.AuditStore,
    90  		&s.ClusterDiscoveryStore,
    91  		&s.ComplianceStore,
    92  		&s.SessionStore,
    93  		&s.OAuthStore,
    94  		&s.SystemStore,
    95  		&s.WebhookStore,
    96  		&s.CommandStore,
    97  		&s.CommandWebhookStore,
    98  		&s.PreferenceStore,
    99  		&s.LicenseStore,
   100  		&s.TokenStore,
   101  		&s.EmojiStore,
   102  		&s.StatusStore,
   103  		&s.FileInfoStore,
   104  		&s.ReactionStore,
   105  		&s.JobStore,
   106  		&s.UserAccessTokenStore,
   107  		&s.ChannelMemberHistoryStore,
   108  		&s.PluginStore,
   109  		&s.RoleStore,
   110  	)
   111  }