Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft. Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch. WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b umbenannten Parameter angeglichen. Dabei behoben: - 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue" gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day. - Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine CSS-Klasse gab - jetzt "success" wie laufende Instanzen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
3.9 KiB
C#
116 lines
3.9 KiB
C#
using System.Text.Json;
|
|
using ClawdDotNet.App.Services;
|
|
using ClawdDotNet.Core.Config;
|
|
using Shouldly;
|
|
using ClawdDotNet.Core.Instances;
|
|
|
|
namespace ClawdDotNet.App.Tests.Services;
|
|
|
|
/// <summary>
|
|
/// The other half of #375: existing instances carry <c>"logDirectory": "./Logs"</c>
|
|
/// in their <c>InstanceSettings.json</c> — <see cref="InstanceDirectoryManager.CreateInstance"/>
|
|
/// wrote it there. On loading it becomes "empty".
|
|
///
|
|
/// <para>Since #528 (stage 1) both spellings point to the same place anyway:
|
|
/// <c><Instanz>/Logs</c>. The empty value says so without pinning it down — if
|
|
/// the instance moves, the log moves with it.</para>
|
|
///
|
|
/// Whoever deliberately entered a different path keeps it.
|
|
/// </summary>
|
|
public sealed class InstanceLogDirectoryMigrationTests : IDisposable
|
|
{
|
|
private readonly string _instancesDir;
|
|
private readonly InstanceDirectoryManager _manager;
|
|
|
|
public InstanceLogDirectoryMigrationTests()
|
|
{
|
|
_instancesDir = Path.Combine(
|
|
Path.GetTempPath(), "clawd-tests", Guid.NewGuid().ToString("N"), "Instances");
|
|
_manager = new InstanceDirectoryManager(_instancesDir);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
try { Directory.Delete(Path.GetDirectoryName(_instancesDir)!, recursive: true); }
|
|
catch { /* Cleaning up is secondary */ }
|
|
}
|
|
|
|
/// <summary>Creates an instance and sets logDirectory in the file to the legacy value.</summary>
|
|
private string InstanceWithLogDirectory(string value)
|
|
{
|
|
var dir = _manager.CreateInstance("Test");
|
|
var path = Path.Combine(dir, "InstanceSettings.json");
|
|
|
|
var config = JsonSerializer.Deserialize<InstanceConfig>(File.ReadAllText(path))!;
|
|
config.LogDirectory = value;
|
|
File.WriteAllText(path, JsonSerializer.Serialize(config));
|
|
|
|
return dir;
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("./Logs")]
|
|
[InlineData(@".\Logs")]
|
|
[InlineData("Logs")]
|
|
public void Die_alte_Vorbelegung_wird_zu_keiner_Angabe(string alt)
|
|
{
|
|
var dir = InstanceWithLogDirectory(alt);
|
|
|
|
_manager.LoadInstanceConfig(dir).LogDirectory.ShouldBe("");
|
|
}
|
|
|
|
[Fact]
|
|
public void Ein_bewusst_gesetzter_Pfad_bleibt_stehen()
|
|
{
|
|
var eigen = Path.Combine(Path.GetTempPath(), "clawd-eigene-logs");
|
|
var dir = InstanceWithLogDirectory(eigen);
|
|
|
|
_manager.LoadInstanceConfig(dir).LogDirectory.ShouldBe(eigen);
|
|
}
|
|
|
|
[Fact]
|
|
public void Die_Datei_wird_beim_Laden_nicht_zurueckgeschrieben()
|
|
{
|
|
// The migration only applies in memory. A load must not touch anything —
|
|
// only the next save makes the legacy value disappear.
|
|
var dir = InstanceWithLogDirectory("./Logs");
|
|
var path = Path.Combine(dir, "InstanceSettings.json");
|
|
|
|
_manager.LoadInstanceConfig(dir);
|
|
|
|
File.ReadAllText(path).ShouldContain("./Logs");
|
|
}
|
|
|
|
[Fact]
|
|
public void Eine_neue_Instanz_bekommt_gar_keinen_Wert()
|
|
{
|
|
var dir = _manager.CreateInstance("Frisch");
|
|
var config = _manager.LoadInstanceConfig(dir);
|
|
|
|
config.LogDirectory.ShouldBe("");
|
|
config.BackupDirectory.ShouldBe("");
|
|
|
|
File.ReadAllText(Path.Combine(dir, "InstanceSettings.json")).ShouldNotContain("./Logs");
|
|
}
|
|
|
|
/// <summary>
|
|
/// The actual purpose of stage 1: two freshly created instances do not log
|
|
/// and back up into the same folder.
|
|
/// </summary>
|
|
[Fact]
|
|
public void Zwei_frische_Instanzen_landen_nicht_im_selben_Ordner()
|
|
{
|
|
var a = _manager.CreateInstance("Eins");
|
|
var b = _manager.CreateInstance("Zwei");
|
|
|
|
var configA = _manager.LoadInstanceConfig(a);
|
|
var configB = _manager.LoadInstanceConfig(b);
|
|
|
|
AppHost.ResolveLogDirectory(configA, a)
|
|
.ShouldNotBe(AppHost.ResolveLogDirectory(configB, b));
|
|
|
|
AppHost.ResolveBackupDirectory(configA, a)
|
|
.ShouldNotBe(AppHost.ResolveBackupDirectory(configB, b));
|
|
}
|
|
}
|