Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
using Omika.Diagnostics.Models;
|
||||
using Omika.Diagnostics.Queries;
|
||||
using Omika.Diagnostics.Repositories;
|
||||
|
||||
namespace Omika.Diagnostics.Tests.Fakes;
|
||||
|
||||
/// <summary>
|
||||
/// Simule PostgreSQL DOWN (§52) : toutes les opérations lèvent, la sonde retourne
|
||||
/// <c>false</c>. L'importeur doit survivre (résultat retryable), laisser le JSONL
|
||||
/// intact et ne pas avancer le checkpoint.
|
||||
/// </summary>
|
||||
public sealed class ThrowingDiagnosticRepository : IDiagnosticEventRepository
|
||||
{
|
||||
public Task<int> InsertBatchAsync(
|
||||
IReadOnlyList<DiagnosticEventRecord> events,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticQueryResult<DiagnosticEventRecord>> QueryAsync(
|
||||
DiagnosticEventQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticEventRecord>> GetByTraceIdAsync(
|
||||
Guid traceId,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticEventRecord>> GetByOperationIdAsync(
|
||||
Guid operationId,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<bool> IsAvailableAsync(CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(false);
|
||||
|
||||
public Task<int> DeleteOlderThanAsync(
|
||||
DateTimeOffset cutoff,
|
||||
int batchSize,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<long> DeleteErrorGroupAsync(
|
||||
DiagnosticErrorGroupIdentity identity,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticGroupCount>> CountGroupedAsync(
|
||||
DiagnosticGroupDimension dimension,
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticBucketCount>> CountByTimeBucketAsync(
|
||||
DiagnosticTimeBucket bucket,
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticBucketClientCount>> CountByTimeBucketAndClientAsync(
|
||||
DiagnosticTimeBucket bucket,
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticLicenseErrorCount>> CountLicensesByErrorsAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticGroupCount>> CountErrorsByClientAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticQueryResult<DiagnosticEventRecord>> SearchAsync(
|
||||
DiagnosticSearchQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticErrorGroup>> GroupErrorsAsync(
|
||||
DiagnosticErrorGroupQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<long> CountAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<long> CountErrorGroupsAsync(
|
||||
DiagnosticErrorGroupQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticDurationStats?> GetDurationStatsAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticDurationByEventCode>> GetTopDurationByEventCodeAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticVersionSummary>> GetVersionSummariesAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticVersionTotals> GetVersionTotalsAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticSyncSummary> GetSyncSummaryAsync(
|
||||
DiagnosticAggregateQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticErrorGroup?> GetErrorGroupAsync(
|
||||
DiagnosticErrorGroupOccurrenceQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticEventRecord>> GetErrorGroupOccurrencesAsync(
|
||||
DiagnosticErrorGroupOccurrenceQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticGroupCount>> CountErrorGroupByClientAsync(
|
||||
DiagnosticErrorGroupOccurrenceQuery query,
|
||||
int limit,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticLicenseErrorCount>> CountErrorGroupByLicenseAsync(
|
||||
DiagnosticErrorGroupOccurrenceQuery query,
|
||||
int limit,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DiagnosticEventRecord?> GetByIdAsync(
|
||||
long id,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticEventRecord>> GetCorrelatedAsync(
|
||||
DiagnosticCorrelationQuery query,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
query.Validate();
|
||||
|
||||
// Sans identifiant, le contrat exige « aucune requête » (§T3/17) : le résultat
|
||||
// vide est retourné SANS toucher PostgreSQL, même si la base est down.
|
||||
return query.HasAnyIdentifier
|
||||
? throw new InvalidOperationException("PostgreSQL DOWN simulé")
|
||||
: Task.FromResult<IReadOnlyList<DiagnosticEventRecord>>([]);
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<string>> GetFilterOptionsAsync(
|
||||
DiagnosticFilterDimension dimension,
|
||||
DateTimeOffset fromUtc,
|
||||
int limit,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DiagnosticRecentCorrelation>> GetRecentCorrelationsAsync(
|
||||
DiagnosticCorrelationDimension dimension,
|
||||
DateTimeOffset fromUtc,
|
||||
int limit,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<long> CountActiveDevicesAsync(
|
||||
DeviceFleetQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DeviceDistribution>> CountDevicesGroupedAsync(
|
||||
DeviceFleetDimension dimension,
|
||||
DeviceFleetQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<DeviceFleetQueryResult> GetDevicesAsync(
|
||||
DeviceFleetQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<DeviceDistribution>> CountDevicesByLicenseAsync(
|
||||
DeviceFleetQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<ScreenUsageRecord>> GetScreenUsageAsync(
|
||||
UsageTelemetryQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
|
||||
public Task<IReadOnlyList<FeatureUsageRecord>> GetFeatureUsageAsync(
|
||||
UsageTelemetryQuery query,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new InvalidOperationException("PostgreSQL DOWN simulé");
|
||||
}
|
||||
Reference in New Issue
Block a user