github.com/xzl8028/xenia-server@v0.0.0-20190809101854-18450a97da63/store/storetest/store.go (about)

     1  // Copyright (c) 2017-present Xenia, 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/xzl8028/xenia-server/store"
    10  	"github.com/xzl8028/xenia-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  	BotStore                  mocks.BotStore
    27  	TaskStore                 mocks.TaskStore
    28  	AuditStore                mocks.AuditStore
    29  	ClusterDiscoveryStore     mocks.ClusterDiscoveryStore
    30  	ComplianceStore           mocks.ComplianceStore
    31  	SessionStore              mocks.SessionStore
    32  	OAuthStore                mocks.OAuthStore
    33  	SystemStore               mocks.SystemStore
    34  	WebhookStore              mocks.WebhookStore
    35  	CommandStore              mocks.CommandStore
    36  	CommandWebhookStore       mocks.CommandWebhookStore
    37  	PreferenceStore           mocks.PreferenceStore
    38  	LicenseStore              mocks.LicenseStore
    39  	TokenStore                mocks.TokenStore
    40  	EmojiStore                mocks.EmojiStore
    41  	StatusStore               mocks.StatusStore
    42  	FileInfoStore             mocks.FileInfoStore
    43  	ReactionStore             mocks.ReactionStore
    44  	JobStore                  mocks.JobStore
    45  	UserAccessTokenStore      mocks.UserAccessTokenStore
    46  	PluginStore               mocks.PluginStore
    47  	ChannelMemberHistoryStore mocks.ChannelMemberHistoryStore
    48  	RoleStore                 mocks.RoleStore
    49  	SchemeStore               mocks.SchemeStore
    50  	TermsOfServiceStore       mocks.TermsOfServiceStore
    51  	GroupStore                mocks.GroupStore
    52  	UserTermsOfServiceStore   mocks.UserTermsOfServiceStore
    53  	LinkMetadataStore         mocks.LinkMetadataStore
    54  }
    55  
    56  func (s *Store) Team() store.TeamStore                             { return &s.TeamStore }
    57  func (s *Store) Channel() store.ChannelStore                       { return &s.ChannelStore }
    58  func (s *Store) Post() store.PostStore                             { return &s.PostStore }
    59  func (s *Store) User() store.UserStore                             { return &s.UserStore }
    60  func (s *Store) Bot() store.BotStore                               { return &s.BotStore }
    61  func (s *Store) Task() store.TaskStore                             { return &s.TaskStore }
    62  func (s *Store) Audit() store.AuditStore                           { return &s.AuditStore }
    63  func (s *Store) ClusterDiscovery() store.ClusterDiscoveryStore     { return &s.ClusterDiscoveryStore }
    64  func (s *Store) Compliance() store.ComplianceStore                 { return &s.ComplianceStore }
    65  func (s *Store) Session() store.SessionStore                       { return &s.SessionStore }
    66  func (s *Store) OAuth() store.OAuthStore                           { return &s.OAuthStore }
    67  func (s *Store) System() store.SystemStore                         { return &s.SystemStore }
    68  func (s *Store) Webhook() store.WebhookStore                       { return &s.WebhookStore }
    69  func (s *Store) Command() store.CommandStore                       { return &s.CommandStore }
    70  func (s *Store) CommandWebhook() store.CommandWebhookStore         { return &s.CommandWebhookStore }
    71  func (s *Store) Preference() store.PreferenceStore                 { return &s.PreferenceStore }
    72  func (s *Store) License() store.LicenseStore                       { return &s.LicenseStore }
    73  func (s *Store) Token() store.TokenStore                           { return &s.TokenStore }
    74  func (s *Store) Emoji() store.EmojiStore                           { return &s.EmojiStore }
    75  func (s *Store) Status() store.StatusStore                         { return &s.StatusStore }
    76  func (s *Store) FileInfo() store.FileInfoStore                     { return &s.FileInfoStore }
    77  func (s *Store) Reaction() store.ReactionStore                     { return &s.ReactionStore }
    78  func (s *Store) Job() store.JobStore                               { return &s.JobStore }
    79  func (s *Store) UserAccessToken() store.UserAccessTokenStore       { return &s.UserAccessTokenStore }
    80  func (s *Store) Plugin() store.PluginStore                         { return &s.PluginStore }
    81  func (s *Store) Role() store.RoleStore                             { return &s.RoleStore }
    82  func (s *Store) Scheme() store.SchemeStore                         { return &s.SchemeStore }
    83  func (s *Store) TermsOfService() store.TermsOfServiceStore         { return &s.TermsOfServiceStore }
    84  func (s *Store) UserTermsOfService() store.UserTermsOfServiceStore { return &s.UserTermsOfServiceStore }
    85  func (s *Store) ChannelMemberHistory() store.ChannelMemberHistoryStore {
    86  	return &s.ChannelMemberHistoryStore
    87  }
    88  func (s *Store) Group() store.GroupStore               { return &s.GroupStore }
    89  func (s *Store) LinkMetadata() store.LinkMetadataStore { return &s.LinkMetadataStore }
    90  func (s *Store) MarkSystemRanUnitTests()               { /* do nothing */ }
    91  func (s *Store) Close()                                { /* do nothing */ }
    92  func (s *Store) LockToMaster()                         { /* do nothing */ }
    93  func (s *Store) UnlockFromMaster()                     { /* do nothing */ }
    94  func (s *Store) DropAllTables()                        { /* do nothing */ }
    95  func (s *Store) TotalMasterDbConnections() int         { return 1 }
    96  func (s *Store) TotalReadDbConnections() int           { return 1 }
    97  func (s *Store) TotalSearchDbConnections() int         { return 1 }
    98  
    99  func (s *Store) AssertExpectations(t mock.TestingT) bool {
   100  	return mock.AssertExpectationsForObjects(t,
   101  		&s.TeamStore,
   102  		&s.ChannelStore,
   103  		&s.PostStore,
   104  		&s.UserStore,
   105  		&s.BotStore,
   106  		&s.TaskStore,
   107  		&s.AuditStore,
   108  		&s.ClusterDiscoveryStore,
   109  		&s.ComplianceStore,
   110  		&s.SessionStore,
   111  		&s.OAuthStore,
   112  		&s.SystemStore,
   113  		&s.WebhookStore,
   114  		&s.CommandStore,
   115  		&s.CommandWebhookStore,
   116  		&s.PreferenceStore,
   117  		&s.LicenseStore,
   118  		&s.TokenStore,
   119  		&s.EmojiStore,
   120  		&s.StatusStore,
   121  		&s.FileInfoStore,
   122  		&s.ReactionStore,
   123  		&s.JobStore,
   124  		&s.UserAccessTokenStore,
   125  		&s.ChannelMemberHistoryStore,
   126  		&s.PluginStore,
   127  		&s.RoleStore,
   128  		&s.SchemeStore,
   129  	)
   130  }