File tree 1 file changed +3
-15
lines changed
1 file changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -7714,21 +7714,6 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
7714
7714
return database.User {}, err
7715
7715
}
7716
7716
7717
- // There is a common bug when using dbmem that 2 inserted users have the
7718
- // same created_at time. This causes user order to not be deterministic,
7719
- // which breaks some unit tests.
7720
- // To fix this, we make sure that the created_at time is always greater
7721
- // than the last user's created_at time.
7722
- allUsers , _ := q .GetUsers (context .Background (), database.GetUsersParams {})
7723
- if len (allUsers ) > 0 {
7724
- lastUser := allUsers [len (allUsers )- 1 ]
7725
- if arg .CreatedAt .Before (lastUser .CreatedAt ) ||
7726
- arg .CreatedAt .Equal (lastUser .CreatedAt ) {
7727
- // 1 ms is a good enough buffer.
7728
- arg .CreatedAt = lastUser .CreatedAt .Add (time .Millisecond )
7729
- }
7730
- }
7731
-
7732
7717
q .mutex .Lock ()
7733
7718
defer q .mutex .Unlock ()
7734
7719
@@ -7756,6 +7741,9 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
7756
7741
LoginType : arg .LoginType ,
7757
7742
}
7758
7743
q .users = append (q .users , user )
7744
+ sort .Slice (q .users , func (i , j int ) bool {
7745
+ return q .users [i ].CreatedAt .Before (q .users [j ].CreatedAt )
7746
+ })
7759
7747
return user , nil
7760
7748
}
7761
7749
You can’t perform that action at this time.
0 commit comments