-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/8.0] Use TokenCredential for Cosmos tests (#33966)
- Loading branch information
1 parent
67fd137
commit 15d21bf
Showing
15 changed files
with
178 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
[Flags] | ||
public enum CosmosCondition | ||
{ | ||
UsesTokenCredential = 1 << 0, | ||
DoesNotUseTokenCredential = 1 << 1, | ||
} |
38 changes: 38 additions & 0 deletions
38
test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosConditionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; | ||
|
||
namespace Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] | ||
public sealed class CosmosConditionAttribute(CosmosCondition conditions) : Attribute, ITestCondition | ||
{ | ||
public CosmosCondition Conditions { get; set; } = conditions; | ||
|
||
public ValueTask<bool> IsMetAsync() | ||
{ | ||
var isMet = true; | ||
|
||
if (Conditions.HasFlag(CosmosCondition.UsesTokenCredential)) | ||
{ | ||
isMet &= TestEnvironment.UseTokenCredential; | ||
} | ||
|
||
if (Conditions.HasFlag(CosmosCondition.DoesNotUseTokenCredential)) | ||
{ | ||
isMet &= !TestEnvironment.UseTokenCredential; | ||
} | ||
|
||
return ValueTask.FromResult(isMet); | ||
} | ||
|
||
public string SkipReason | ||
=> string.Format( | ||
"The test Cosmos account does not meet these conditions: '{0}'", | ||
string.Join( | ||
", ", Enum.GetValues(typeof(CosmosCondition)) | ||
.Cast<Enum>() | ||
.Where(Conditions.HasFlag) | ||
.Select(f => Enum.GetName(typeof(CosmosCondition), f)))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.