fix(uns): reject tag create on non-existent equipment + narrow JSON catch (review)

This commit is contained in:
Joseph Doherty
2026-06-08 13:06:45 -04:00
parent 5a392c5db0
commit 77024f87da
2 changed files with 21 additions and 1 deletions
@@ -219,6 +219,23 @@ public sealed class UnsTreeServiceTagTests
result.Error.ShouldBe("Tag 'TAG-1' already exists.");
}
/// <summary>Creating a tag for an equipment id that does not exist returns a not-found error.</summary>
[Fact]
public async Task CreateTag_unresolvable_equipment_returns_error()
{
var (service, dbName) = Fresh();
SeedHierarchyAndDrivers(dbName, equipmentCluster: "MAIN", seedEquipmentDriver: true);
var result = await service.CreateTagAsync("EQ-NOPE", Input("TAG-1", "speed", "DRV-EQ"));
result.Ok.ShouldBeFalse();
result.Error.ShouldNotBeNull();
result.Error.ShouldContain("not found");
using var db = UnsTreeTestDb.CreateNamed(dbName);
db.Tags.Any(t => t.TagId == "TAG-1").ShouldBeFalse();
}
/// <summary>Creating a tag whose Name already exists on the same equipment is blocked.</summary>
[Fact]
public async Task CreateTag_duplicate_name_on_equipment_blocked()