Skip to content

Commit 1ab93dd

Browse files
committed
CI: SourceBranchName - so tests from different branches don't collide
1 parent 2aac7ae commit 1ab93dd

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ trigger:
33
- develop
44
- feature/*
55
- refs/tags/*
6+
- releases/*
67

78
variables:
89
solution: 'Thinktecture.EntityFrameworkCore.sln'
910
buildConfiguration: 'Release'
11+
SourceBranchName: '$(Build.SourceBranchName)'
1012

1113
pool:
1214
vmImage: 'windows-latest'

tests/Thinktecture.EntityFrameworkCore.SqlServer.Tests/Extensions/QueryableExtensionsTests/WithTableHints.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace Thinktecture.Extensions.QueryableExtensionsTests;
44

55
public class WithTableHints : IntegrationTestsBase
66
{
7+
private string? _escapedSchema;
8+
private string EscapedSchema => _escapedSchema ??= $"[{ActDbContext.Schema}]";
9+
710
public WithTableHints(ITestOutputHelper testOutputHelper)
811
: base(testOutputHelper, true)
912
{
@@ -15,7 +18,7 @@ public async Task Should_add_table_hints_to_table()
1518
var query = ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock);
1619

1720
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField]" + Environment.NewLine +
18-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)");
21+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)");
1922

2023
var result = await query.ToListAsync();
2124
result.Should().BeEmpty();
@@ -27,12 +30,12 @@ public void Should_not_mess_up_table_hints()
2730
var query = ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock);
2831

2932
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField]" + Environment.NewLine +
30-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)");
33+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)");
3134

3235
query = ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.UpdLock);
3336

3437
query.ToQueryString().Should().Be(@"SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField]" + Environment.NewLine +
35-
"FROM [_tests].[TestEntities] AS [t] WITH (UPDLOCK)");
38+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (UPDLOCK)");
3639
}
3740

3841
[Fact]
@@ -42,8 +45,8 @@ public async Task Should_add_table_hints_to_table_without_touching_included_navi
4245
.Include(e => e.Children);
4346

4447
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField], [t0].[Id], [t0].[ConvertibleClass], [t0].[Count], [t0].[Name], [t0].[ParentId], [t0].[PropertyWithBackingField], [t0].[RequiredName], [t0].[_privateField]" + Environment.NewLine +
45-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
46-
"LEFT JOIN [_tests].[TestEntities] AS [t0] ON [t].[Id] = [t0].[ParentId]" + Environment.NewLine +
48+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
49+
$"LEFT JOIN {EscapedSchema}.[TestEntities] AS [t0] ON [t].[Id] = [t0].[ParentId]" + Environment.NewLine +
4750
"ORDER BY [t].[Id]");
4851

4952
var result = await query.ToListAsync();
@@ -57,35 +60,35 @@ public async Task Should_work_with_joins_on_itself()
5760
.Join(ActDbContext.TestEntities, e => e.Id, e => e.Id, (e1, e2) => new { e1, e2 });
5861

5962
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField], [t0].[Id], [t0].[ConvertibleClass], [t0].[Count], [t0].[Name], [t0].[ParentId], [t0].[PropertyWithBackingField], [t0].[RequiredName], [t0].[_privateField]" + Environment.NewLine +
60-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
61-
"INNER JOIN [_tests].[TestEntities] AS [t0] ON [t].[Id] = [t0].[Id]");
63+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
64+
$"INNER JOIN {EscapedSchema}.[TestEntities] AS [t0] ON [t].[Id] = [t0].[Id]");
6265

6366
(await query.ToListAsync()).Should().BeEmpty();
6467

6568
query = ActDbContext.TestEntities
6669
.Join(ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock), e => e.Id, e => e.Id, (e1, e2) => new { e1, e2 });
6770

6871
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField], [t0].[Id], [t0].[ConvertibleClass], [t0].[Count], [t0].[Name], [t0].[ParentId], [t0].[PropertyWithBackingField], [t0].[RequiredName], [t0].[_privateField]" + Environment.NewLine +
69-
"FROM [_tests].[TestEntities] AS [t]" + Environment.NewLine +
70-
"INNER JOIN [_tests].[TestEntities] AS [t0] WITH (NOLOCK) ON [t].[Id] = [t0].[Id]");
72+
$"FROM {EscapedSchema}.[TestEntities] AS [t]" + Environment.NewLine +
73+
$"INNER JOIN {EscapedSchema}.[TestEntities] AS [t0] WITH (NOLOCK) ON [t].[Id] = [t0].[Id]");
7174

7275
(await query.ToListAsync()).Should().BeEmpty();
7376

7477
query = ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock)
7578
.Join(ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock), e => e.Id, e => e.Id, (e1, e2) => new { e1, e2 });
7679

7780
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField], [t0].[Id], [t0].[ConvertibleClass], [t0].[Count], [t0].[Name], [t0].[ParentId], [t0].[PropertyWithBackingField], [t0].[RequiredName], [t0].[_privateField]" + Environment.NewLine +
78-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
79-
"INNER JOIN [_tests].[TestEntities] AS [t0] WITH (NOLOCK) ON [t].[Id] = [t0].[Id]");
81+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
82+
$"INNER JOIN {EscapedSchema}.[TestEntities] AS [t0] WITH (NOLOCK) ON [t].[Id] = [t0].[Id]");
8083

8184
(await query.ToListAsync()).Should().BeEmpty();
8285

8386
query = ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.NoLock)
8487
.Join(ActDbContext.TestEntities.WithTableHints(SqlServerTableHint.UpdLock), e => e.Id, e => e.Id, (e1, e2) => new { e1, e2 });
8588

8689
query.ToQueryString().Should().Be("SELECT [t].[Id], [t].[ConvertibleClass], [t].[Count], [t].[Name], [t].[ParentId], [t].[PropertyWithBackingField], [t].[RequiredName], [t].[_privateField], [t0].[Id], [t0].[ConvertibleClass], [t0].[Count], [t0].[Name], [t0].[ParentId], [t0].[PropertyWithBackingField], [t0].[RequiredName], [t0].[_privateField]" + Environment.NewLine +
87-
"FROM [_tests].[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
88-
"INNER JOIN [_tests].[TestEntities] AS [t0] WITH (UPDLOCK) ON [t].[Id] = [t0].[Id]");
90+
$"FROM {EscapedSchema}.[TestEntities] AS [t] WITH (NOLOCK)" + Environment.NewLine +
91+
$"INNER JOIN {EscapedSchema}.[TestEntities] AS [t0] WITH (UPDLOCK) ON [t].[Id] = [t0].[Id]");
8992

9093
(await query.ToListAsync()).Should().BeEmpty();
9194
}
@@ -96,11 +99,11 @@ public async Task Should_add_table_hints_to_table_without_touching_owned_entitie
9699
var query = ActDbContext.TestEntities_Own_SeparateMany_SeparateMany.WithTableHints(SqlServerTableHint.NoLock);
97100

98101
query.ToQueryString().Should().Be(@"SELECT [t].[Id], [t0].[TestEntity_Owns_SeparateMany_SeparateManyId], [t0].[Id], [t0].[IntColumn], [t0].[StringColumn], [t0].[OwnedEntity_Owns_SeparateManyTestEntity_Owns_SeparateMany_SeparateManyId], [t0].[OwnedEntity_Owns_SeparateManyId], [t0].[Id0], [t0].[IntColumn0], [t0].[StringColumn0]" + Environment.NewLine +
99-
"FROM [_tests].[TestEntities_Own_SeparateMany_SeparateMany] AS [t] WITH (NOLOCK)" + Environment.NewLine +
102+
$"FROM {EscapedSchema}.[TestEntities_Own_SeparateMany_SeparateMany] AS [t] WITH (NOLOCK)" + Environment.NewLine +
100103
"LEFT JOIN (" + Environment.NewLine +
101104
" SELECT [s].[TestEntity_Owns_SeparateMany_SeparateManyId], [s].[Id], [s].[IntColumn], [s].[StringColumn], [s0].[OwnedEntity_Owns_SeparateManyTestEntity_Owns_SeparateMany_SeparateManyId], [s0].[OwnedEntity_Owns_SeparateManyId], [s0].[Id] AS [Id0], [s0].[IntColumn] AS [IntColumn0], [s0].[StringColumn] AS [StringColumn0]" + Environment.NewLine +
102-
" FROM [_tests].[SeparateEntitiesMany_SeparateEntitiesMany] AS [s]" + Environment.NewLine +
103-
" LEFT JOIN [_tests].[SeparateEntitiesMany_SeparateEntitiesMany_Inner] AS [s0] ON ([s].[TestEntity_Owns_SeparateMany_SeparateManyId] = [s0].[OwnedEntity_Owns_SeparateManyTestEntity_Owns_SeparateMany_SeparateManyId]) AND ([s].[Id] = [s0].[OwnedEntity_Owns_SeparateManyId])" + Environment.NewLine +
105+
$" FROM {EscapedSchema}.[SeparateEntitiesMany_SeparateEntitiesMany] AS [s]" + Environment.NewLine +
106+
$" LEFT JOIN {EscapedSchema}.[SeparateEntitiesMany_SeparateEntitiesMany_Inner] AS [s0] ON ([s].[TestEntity_Owns_SeparateMany_SeparateManyId] = [s0].[OwnedEntity_Owns_SeparateManyTestEntity_Owns_SeparateMany_SeparateManyId]) AND ([s].[Id] = [s0].[OwnedEntity_Owns_SeparateManyId])" + Environment.NewLine +
104107
") AS [t0] ON [t].[Id] = [t0].[TestEntity_Owns_SeparateMany_SeparateManyId]" + Environment.NewLine +
105108
"ORDER BY [t].[Id], [t0].[TestEntity_Owns_SeparateMany_SeparateManyId], [t0].[Id], [t0].[OwnedEntity_Owns_SeparateManyTestEntity_Owns_SeparateMany_SeparateManyId], [t0].[OwnedEntity_Owns_SeparateManyId]");
106109

0 commit comments

Comments
 (0)