fix(uns): reject tag create on non-existent equipment + narrow JSON catch (review)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user