Skip to content

Fix non-deterministic tests that fail on postgres #27280

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
1 commit merged into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public override Task Average_Grouped_from_LINQ_101(bool async)
ss => from p in ss.Set<ProductForLinq>()
group p by p.Category
into g
select new { Category = g.Key, AveragePrice = g.Average(p => p.UnitPrice) });
select new { Category = g.Key, AveragePrice = g.Average(p => p.UnitPrice) },
elementSorter: e => (e.Category, e.AveragePrice));

public class Ef6GroupByInMemoryFixture : Ef6GroupByFixtureBase
{
Expand Down
3 changes: 2 additions & 1 deletion test/EFCore.Specification.Tests/Query/Ef6GroupByTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ into g
ss => from p in ss.Set<ProductForLinq>()
group p by p.Category
into g
select new { Category = g.Key, AveragePrice = Math.Round(g.Average(p => p.UnitPrice) - 0.0000005m, 6) });
select new { Category = g.Key, AveragePrice = Math.Round(g.Average(p => p.UnitPrice) - 0.0000005m, 6) },
elementSorter: e => (e.Category, e.AveragePrice));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public virtual Task Reverse_in_subquery_via_pushdown(bool async)
.Take(5)
.Distinct()
.Select(e => new { e.EmployeeID, e.City }),
assertOrder: true);
elementSorter: e => e.EmployeeID);

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down
18 changes: 15 additions & 3 deletions test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,21 @@ public virtual async Task Aggregate_over_subquery_in_group_by_projection(bool as
? await query.ToListAsync()
: query.ToList();

Assert.Collection(orders,
t => Assert.Equal(10, t.CustomerMinHourlyRate),
t => Assert.Equal(20, t.CustomerMinHourlyRate));
Assert.Collection(orders.OrderBy(x => x.CustomerId),
t =>
{
Assert.Equal(1, t.CustomerId);
Assert.Equal(10, t.CustomerMinHourlyRate);
Assert.Equal(11, t.HourlyRate);
Assert.Equal(1, t.Count);
},
t =>
{
Assert.Equal(2, t.CustomerId);
Assert.Equal(20, t.CustomerMinHourlyRate);
Assert.Equal(20, t.HourlyRate);
Assert.Equal(1, t.Count);
});
}

protected class Context27083 : DbContext
Expand Down