From aaeaaf716b3706012afb562635ccefacc6145662 Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Tue, 7 Sep 2021 19:09:48 +0200 Subject: [PATCH] Fix flaky TestCreateDefaultMemberships (#18330) --- app/syncables_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/syncables_test.go b/app/syncables_test.go index 40cb5039a9..ae8a171eb0 100644 --- a/app/syncables_test.go +++ b/app/syncables_test.go @@ -13,7 +13,6 @@ import ( ) func TestCreateDefaultMemberships(t *testing.T) { - t.Skip("MM-36909") th := Setup(t).InitBasic() defer th.TearDown() @@ -297,14 +296,15 @@ func TestCreateDefaultMemberships(t *testing.T) { t.Errorf("unable to add user to channel: %s", err.Error()) } - timeAfterLeaving := model.GetMillis() + timeAfterLeaving := model.GetMillis() + 1 // Purging channelmemberhistory doesn't re-add user to channel - _, _, nErr := th.App.Srv().Store.ChannelMemberHistory().PermanentDeleteBatchForRetentionPolicies( + deletedCount, _, nErr := th.App.Srv().Store.ChannelMemberHistory().PermanentDeleteBatchForRetentionPolicies( 0, timeBeforeLeaving, 1000, model.RetentionPolicyCursor{}) if nErr != nil { t.Errorf("error permanently deleting channelmemberhistory: %s", nErr.Error()) } + require.Equal(t, int64(1), deletedCount) pErr = th.App.CreateDefaultMemberships(th.Context, scienceChannelGroupSyncable.UpdateAt, false) if pErr != nil { @@ -317,11 +317,12 @@ func TestCreateDefaultMemberships(t *testing.T) { } // Purging channelmemberhistory doesn't re-add user to channel - _, _, nErr = th.App.Srv().Store.ChannelMemberHistory().PermanentDeleteBatchForRetentionPolicies( + deletedCount, _, nErr = th.App.Srv().Store.ChannelMemberHistory().PermanentDeleteBatchForRetentionPolicies( 0, timeAfterLeaving, 1000, model.RetentionPolicyCursor{}) if nErr != nil { t.Errorf("error permanently deleting channelmemberhistory: %s", nErr.Error()) } + require.Equal(t, int64(1), deletedCount) pErr = th.App.CreateDefaultMemberships(th.Context, scienceChannelGroupSyncable.UpdateAt, false) if pErr != nil {