Add unit tests and implementations for MongoDB index models and OpenAPI metadata
- Implemented `MongoIndexModelTests` to verify index models for various stores. - Created `OpenApiMetadataFactory` with methods to generate OpenAPI metadata. - Added tests for `OpenApiMetadataFactory` to ensure expected defaults and URL overrides. - Introduced `ObserverSurfaceSecrets` and `WebhookSurfaceSecrets` for managing secrets. - Developed `RuntimeSurfaceFsClient` and `WebhookSurfaceFsClient` for manifest retrieval. - Added dependency injection tests for `SurfaceEnvironmentRegistration` in both Observer and Webhook contexts. - Implemented tests for secret resolution in `ObserverSurfaceSecretsTests` and `WebhookSurfaceSecretsTests`. - Created `EnsureLinkNotMergeCollectionsMigrationTests` to validate MongoDB migration logic. - Added project files for MongoDB tests and NuGet package mirroring.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using StellaOps.Scanner.Analyzers.Lang;
|
||||
using StellaOps.Scanner.Analyzers.Lang.DotNet.Internal;
|
||||
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
|
||||
|
||||
namespace StellaOps.Scanner.Analyzers.Lang.Tests.DotNet;
|
||||
|
||||
public sealed class DotNetEntrypointResolverTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task SimpleFixtureResolvesSingleEntrypointAsync()
|
||||
{
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
var fixturePath = TestPaths.ResolveFixture("lang", "dotnet", "simple");
|
||||
|
||||
var context = new LanguageAnalyzerContext(fixturePath, TimeProvider.System);
|
||||
var entrypoints = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
|
||||
|
||||
Assert.Single(entrypoints);
|
||||
|
||||
var entrypoint = entrypoints[0];
|
||||
Assert.Equal("Sample.App", entrypoint.Name);
|
||||
Assert.Equal("Sample.App:Microsoft.AspNetCore.App@10.0.0+Microsoft.NETCore.App@10.0.0+net10.0:any+linux+linux-x64+unix+win+win-x86:frameworkdependent", entrypoint.Id);
|
||||
Assert.Contains("net10.0", entrypoint.TargetFrameworks);
|
||||
Assert.Contains("linux-x64", entrypoint.RuntimeIdentifiers);
|
||||
Assert.Equal("Sample.App.deps.json", entrypoint.RelativeDepsPath);
|
||||
Assert.Equal("Sample.App.runtimeconfig.json", entrypoint.RelativeRuntimeConfigPath);
|
||||
Assert.Equal(DotNetPublishKind.FrameworkDependent, entrypoint.PublishKind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeterministicOrderingIsStableAsync()
|
||||
{
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
var fixturePath = TestPaths.ResolveFixture("lang", "dotnet", "multi");
|
||||
|
||||
var context = new LanguageAnalyzerContext(fixturePath, TimeProvider.System);
|
||||
var first = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
|
||||
var second = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
|
||||
|
||||
Assert.Equal(first.Count, second.Count);
|
||||
for (var i = 0; i < first.Count; i++)
|
||||
{
|
||||
Assert.Equal(first[i].Id, second[i].Id);
|
||||
Assert.True(first[i].TargetFrameworks.SequenceEqual(second[i].TargetFrameworks));
|
||||
Assert.True(first[i].RuntimeIdentifiers.SequenceEqual(second[i].RuntimeIdentifiers));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user