@@ -7714,21 +7714,6 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
77147714return database.User {},err
77157715}
77167716
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-
77327717q .mutex .Lock ()
77337718defer q .mutex .Unlock ()
77347719
@@ -7756,6 +7741,9 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
77567741LoginType :arg .LoginType ,
77577742}
77587743q .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+ })
77597747return user ,nil
77607748}
77617749