save progress
This commit is contained in:
@@ -39,7 +39,7 @@ public class ReachabilityAnalyzerTests
|
||||
Assert.Single(result.Paths);
|
||||
Assert.Equal(entry, result.Paths[0].EntrypointId);
|
||||
Assert.Equal(sink, result.Paths[0].SinkId);
|
||||
Assert.Equal(ImmutableArray.Create(entry, mid, sink), result.Paths[0].NodeIds);
|
||||
Assert.Equal(new[] { entry, mid, sink }, result.Paths[0].NodeIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -64,4 +64,3 @@ public class ReachabilityAnalyzerTests
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.ResultDigest));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<UseConcelierTestInfra>false</UseConcelierTestInfra>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\\..\\__Libraries\\StellaOps.Scanner.CallGraph\\StellaOps.Scanner.CallGraph.csproj" />
|
||||
<ProjectReference Include="..\\..\\..\\__Libraries\\StellaOps.Messaging.Testing\\StellaOps.Messaging.Testing.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
|
||||
@@ -1,36 +1,73 @@
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StellaOps.Messaging.Testing.Fixtures;
|
||||
using Moq;
|
||||
using StackExchange.Redis;
|
||||
using StellaOps.Scanner.CallGraph;
|
||||
using StellaOps.Scanner.CallGraph.Caching;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Scanner.CallGraph.Tests;
|
||||
|
||||
[Collection(nameof(ValkeyFixtureCollection))]
|
||||
public class ValkeyCallGraphCacheServiceTests : IAsyncLifetime
|
||||
{
|
||||
private readonly ValkeyFixture _fixture;
|
||||
private ValkeyCallGraphCacheService _cache = null!;
|
||||
|
||||
public ValkeyCallGraphCacheServiceTests(ValkeyFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
}
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
var store = new Dictionary<string, RedisValue>(StringComparer.Ordinal);
|
||||
|
||||
var database = new Mock<IDatabase>(MockBehavior.Loose);
|
||||
database
|
||||
.Setup(db => db.StringGetAsync(It.IsAny<RedisKey>(), It.IsAny<CommandFlags>()))
|
||||
.ReturnsAsync((RedisKey key, CommandFlags _) =>
|
||||
store.TryGetValue(key.ToString(), out var value) ? value : RedisValue.Null);
|
||||
|
||||
database
|
||||
.Setup(db => db.StringSetAsync(
|
||||
It.IsAny<RedisKey>(),
|
||||
It.IsAny<RedisValue>(),
|
||||
It.IsAny<TimeSpan?>(),
|
||||
It.IsAny<When>(),
|
||||
It.IsAny<CommandFlags>()))
|
||||
.ReturnsAsync((RedisKey key, RedisValue value, TimeSpan? _, When _, CommandFlags _) =>
|
||||
{
|
||||
store[key.ToString()] = value;
|
||||
return true;
|
||||
});
|
||||
|
||||
database
|
||||
.Setup(db => db.StringSetAsync(
|
||||
It.IsAny<RedisKey>(),
|
||||
It.IsAny<RedisValue>(),
|
||||
It.IsAny<TimeSpan?>(),
|
||||
It.IsAny<bool>(),
|
||||
It.IsAny<When>(),
|
||||
It.IsAny<CommandFlags>()))
|
||||
.ReturnsAsync((RedisKey key, RedisValue value, TimeSpan? _, bool _, When _, CommandFlags _) =>
|
||||
{
|
||||
store[key.ToString()] = value;
|
||||
return true;
|
||||
});
|
||||
|
||||
var connection = new Mock<IConnectionMultiplexer>(MockBehavior.Loose);
|
||||
connection
|
||||
.Setup(c => c.GetDatabase(It.IsAny<int>(), It.IsAny<object?>()))
|
||||
.Returns(database.Object);
|
||||
|
||||
var options = Options.Create(new CallGraphCacheConfig
|
||||
{
|
||||
Enabled = true,
|
||||
ConnectionString = _fixture.ConnectionString,
|
||||
ConnectionString = "localhost:6379",
|
||||
KeyPrefix = "test:callgraph:",
|
||||
TtlSeconds = 60,
|
||||
EnableGzip = true,
|
||||
CircuitBreaker = new CircuitBreakerConfig { FailureThreshold = 3, TimeoutSeconds = 30, HalfOpenTimeout = 10 }
|
||||
});
|
||||
|
||||
_cache = new ValkeyCallGraphCacheService(options, NullLogger<ValkeyCallGraphCacheService>.Instance);
|
||||
_cache = new ValkeyCallGraphCacheService(
|
||||
options,
|
||||
NullLogger<ValkeyCallGraphCacheService>.Instance,
|
||||
connectionFactory: _ => Task.FromResult(connection.Object));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user