@@ -247,6 +247,15 @@ func (f *fakeMattermostPluginAPI) CreateSession(session *model.Session) (*model.
247247
248248var _ mattermostPluginAPI = (* fakeMattermostPluginAPI )(nil )
249249
250+ func makeService (p * fakeMattermostPluginAPI ) * MattermostService {
251+ return & MattermostService {
252+ MattermostGroupBackend : & MattermostPluginGroupBackend {
253+ API : p ,
254+ },
255+ API : p ,
256+ }
257+ }
258+
250259func TestMattermostFetchUsers (t * testing.T ) {
251260 p := & fakeMattermostPluginAPI {
252261 Users : []* model.User {{
@@ -276,7 +285,7 @@ func TestMattermostFetchUsers(t *testing.T) {
276285 AuthService : "password" ,
277286 }},
278287 }
279- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
288+ m := makeService ( p )
280289
281290 want := []* User [string ]{{
282291 UserID : "id::user::testuser" ,
@@ -319,7 +328,7 @@ func TestMattermostCreateUsersThatAreUnassociated(t *testing.T) {
319328 AuthService : "email" ,
320329 }},
321330 }
322- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
331+ m := makeService ( p )
323332
324333 got , err := m .CreateUsers (context .Background (), []* User [int ]{{
325334 UserID : 1000 ,
@@ -391,7 +400,7 @@ func TestMattermostFetchGroups(t *testing.T) {
391400 UserId : "id::user::testuser" ,
392401 }},
393402 }
394- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
403+ m := makeService ( p )
395404
396405 want := []* Group [string ]{{
397406 GroupID : "id::group::testgroup" ,
@@ -417,7 +426,7 @@ func TestMattermostFetchGroups(t *testing.T) {
417426
418427func TestMattermostCreateUsers (t * testing.T ) {
419428 p := & fakeMattermostPluginAPI {}
420- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
429+ m := makeService ( p )
421430
422431 got , err := m .CreateUsers (context .Background (), []* User [int ]{{
423432 UserID : 1000 ,
@@ -491,7 +500,7 @@ func TestMattermostCreateUsers(t *testing.T) {
491500
492501func TestMattermostCreateGroups (t * testing.T ) {
493502 p := & fakeMattermostPluginAPI {}
494- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
503+ m := makeService ( p )
495504
496505 got , err := m .CreateGroups (context .Background (), []* Group [int ]{{
497506 GroupID : 1000 ,
@@ -588,7 +597,7 @@ func TestMattermostUpdateUsers(t *testing.T) {
588597 DisableWelcomeEmail : true ,
589598 }},
590599 }
591- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
600+ m := makeService ( p )
592601
593602 got , updated , err := m .UpdateUsers (context .Background (), []* User [string ]{{
594603 UserID : "id::user::testuser" ,
@@ -739,7 +748,7 @@ func TestMattermostDeleteGroups(t *testing.T) {
739748 Source : MMPluginSource ,
740749 }},
741750 }
742- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
751+ m := makeService ( p )
743752
744753 err := m .DeleteGroups (context .Background (), []* Group [string ]{{
745754 GroupID : "id::group::testgroup" ,
@@ -780,7 +789,7 @@ func TestMattermostAddGroupMembers(t *testing.T) {
780789 Source : MMPluginSource ,
781790 }},
782791 }
783- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
792+ m := makeService ( p )
784793
785794 err := m .AddGroupMembers (context .Background (), "id::group::testgroup" , []string {"id::user::testuser" })
786795 if err != nil {
@@ -821,7 +830,7 @@ func TestMattermostRemoveGroupMembers(t *testing.T) {
821830 GroupId : "id::group::testgroup" ,
822831 }},
823832 }
824- m := & MattermostService { & MattermostPluginGroupBackend { p }, p }
833+ m := makeService ( p )
825834
826835 err := m .RemoveGroupMembers (context .Background (), "id::group::testgroup" , []string {"id::user::testuser" })
827836 if err != nil {
0 commit comments