Files
Chronos/tests/Titano.App.Tests/Infrastructure/AppEnvironmentTests.cs
T
Claude 815782a708 fix(app): a portable copy in a OneDrive folder keeps its index outside it
BRIEF §6.2 forbids a SQLite index in a synchronised folder. AppEnvironment.Detect now resolves the data folder
through Core.Windows' AppPaths and OneDriveFolders: a portable copy whose .\data would lie under a OneDrive sync
root (a OneDrive folder, or a Desktop or Documents folder backed up into one) keeps its data in
%LOCALAPPDATA%\Titano and stays portable otherwise; AppEnvironment.SyncedFolder names the OneDrive folder so the
user can be told. The pure choice lives in Core/IO/DataLocation (tested on Linux); reading the OneDrive accounts
key no longer fails start-up when it cannot be read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-12 16:02:33 +00:00

35 lines
1.7 KiB
C#

using System.IO;
using Titano.App.Infrastructure;
using Titano.Core.Windows.Shell;
using Titano.Testing;
namespace Titano.App.Tests.Infrastructure;
/// <summary>BRIEF §6.2: the client's data folder, which is never inside a folder OneDrive synchronises.</summary>
public sealed class AppEnvironmentTests(TestContext context)
{
[Test]
public void APortableCopyInOneDriveKeepsItsDataInTheUserFolderAndSaysSo()
{
var oneDrive = context.CreateTempDirectory("onedrive");
var app = Directory.CreateDirectory(Path.Combine(oneDrive, "Desktop", "Titano")).FullName;
File.WriteAllText(Path.Combine(app, PortableMode.MarkerFileName), "");
var local = context.CreateTempDirectory("local");
var environment = AppEnvironment.From(AppPaths.Resolve(app, local, [oneDrive]));
Assert.Equal(Path.Combine(local, "Titano", "titano.db"), environment.DatabasePath);
Assert.True(environment.IsPortable, "still a portable copy: updates fetch the portable zip, no sign-in entry");
Assert.Equal<string?>(oneDrive, environment.SyncedFolder);
Assert.True(Directory.Exists(environment.LogDirectory));
Assert.False(Directory.Exists(Path.Combine(app, "data")), "nothing is written into the synchronised folder");
// Elsewhere (a USB stick) a portable copy keeps its data beside it.
var stick = context.CreateTempDirectory("stick");
File.WriteAllText(Path.Combine(stick, PortableMode.MarkerFileName), "");
var beside = AppEnvironment.From(AppPaths.Resolve(stick, local, [oneDrive]));
Assert.Equal(Path.Combine(stick, "data"), beside.DataDirectory);
Assert.Null(beside.SyncedFolder);
}
}