mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-06 14:49:40 +00:00
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
50 lines
2.1 KiB
C#
50 lines
2.1 KiB
C#
using AIStudio.Tools;
|
|
using AIStudio.Tools.Databases.IndexStore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace AIStudio.Tests.Tools.Databases;
|
|
|
|
/// <summary>
|
|
/// Checks the row the index keeps for a data source as a whole.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Whether a data source has an index at all is read from this row alone. A data source can end up
|
|
/// with no document indexed but with documents known to fail, e.g., a folder of scans without a
|
|
/// text layer, and those failures hang on this row.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public sealed class IndexStoreDataSourceStateTests
|
|
{
|
|
private const string DATA_SOURCE_ID = "6f1d6a4e-6a5e-4c62-9a4f-0f2d2c8b7a11";
|
|
|
|
[Test]
|
|
public async Task ADataSourceWithOnlyFailedDocumentsKeepsItsRowUntilItIsDeleted()
|
|
{
|
|
var token = CancellationToken.None;
|
|
await using var store = await TemporaryIndexStore.CreateAsync();
|
|
|
|
await store.Client.UpsertDataSourceAsync(DATA_SOURCE_ID, "LOCAL_DIRECTORY", "b0a4c4d2-1f3e-4f0a-8c9d-5a6b7c8d9e01", "signature", "source-hash", 3, token);
|
|
await store.Client.UpsertPermanentFailureAsync(
|
|
DATA_SOURCE_ID,
|
|
new PermanentIndexingFailure("d06c4351-2e57-2941-aa4c-d7a814bfa418", "/tmp/test-data/scan.pdf", "fingerprint", FileExtractionErrorCode.NO_CONTENT, "No text could be read.", DateTimeOffset.UtcNow),
|
|
token);
|
|
|
|
Assert.That(
|
|
await store.Client.GetDataSourceStateAsync(DATA_SOURCE_ID, token),
|
|
Is.Not.Null,
|
|
"No document made it into the index, but the failures did. Without the row nothing would remember them, and every run would read the scans again.");
|
|
|
|
await store.Client.DeleteDataSourceAsync(DATA_SOURCE_ID, token);
|
|
|
|
var stateAfterDeletion = await store.Client.GetDataSourceStateAsync(DATA_SOURCE_ID, token);
|
|
await using var context = store.CreateContext();
|
|
var failuresAfterDeletion = await context.PermanentIndexingFailures.CountAsync(token);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(stateAfterDeletion, Is.Null);
|
|
Assert.That(failuresAfterDeletion, Is.Zero, "The failures go with the data source.");
|
|
});
|
|
}
|
|
} |