Просмотр исходного кода

Align 'Other' hardware type with current main

- Move schema addition from frozen v2 to current v3 schema (repo + test copy)
- Add v3 test fixture for kind: Other
- Apply repo code style (dotnet format, explicit-type rules)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Tim Jones 12 часов назад
Родитель
Сommit
861bec0924

+ 2 - 4
RackPeek.Domain/Resources/OtherHardware/DescribeOtherUseCase.cs

@@ -10,10 +10,8 @@ public record OtherDescription(
     Dictionary<string, string> Labels
 );
 
-public class DescribeOtherUseCase(IResourceCollection repository) : IUseCase
-{
-    public async Task<OtherDescription> ExecuteAsync(string name)
-    {
+public class DescribeOtherUseCase(IResourceCollection repository) : IUseCase {
+    public async Task<OtherDescription> ExecuteAsync(string name) {
         name = Normalize.HardwareName(name);
         ThrowIfInvalid.ResourceName(name);
 

+ 1 - 2
RackPeek.Domain/Resources/OtherHardware/Other.cs

@@ -1,7 +1,6 @@
 namespace RackPeek.Domain.Resources.OtherHardware;
 
-public class Other : Hardware.Hardware
-{
+public class Other : Hardware.Hardware {
     public const string KindLabel = "Other";
     public string? Model { get; set; }
     public string? Description { get; set; }

+ 3 - 5
RackPeek.Domain/Resources/OtherHardware/OtherHardwareReport.cs

@@ -12,11 +12,9 @@ public record OtherHardwareRow(
     string Description
 );
 
-public class OtherHardwareReportUseCase(IResourceCollection repository) : IUseCase
-{
-    public async Task<OtherHardwareReport> ExecuteAsync()
-    {
-        var others = await repository.GetAllOfTypeAsync<Other>();
+public class OtherHardwareReportUseCase(IResourceCollection repository) : IUseCase {
+    public async Task<OtherHardwareReport> ExecuteAsync() {
+        IReadOnlyList<Other> others = await repository.GetAllOfTypeAsync<Other>();
 
         var rows = others.Select(o => new OtherHardwareRow(
             o.Name,

+ 2 - 4
RackPeek.Domain/Resources/OtherHardware/UpdateOtherUseCase.cs

@@ -3,15 +3,13 @@ using RackPeek.Domain.Persistence;
 
 namespace RackPeek.Domain.Resources.OtherHardware;
 
-public class UpdateOtherUseCase(IResourceCollection repository) : IUseCase
-{
+public class UpdateOtherUseCase(IResourceCollection repository) : IUseCase {
     public async Task ExecuteAsync(
         string name,
         string? model = null,
         string? description = null,
         string? notes = null
-    )
-    {
+    ) {
         name = Normalize.HardwareName(name);
         ThrowIfInvalid.ResourceName(name);
 

+ 8 - 0
Tests/TestConfigs/v3/12-other.yaml

@@ -0,0 +1,8 @@
+version: 3
+resources:
+  - kind: Other
+    name: unifi-radio-01
+    tags:
+      - radio
+    model: Building Bridge XG
+    description: Microwave radio bridge for site-to-site connectivity

+ 3 - 0
Tests/Tests.csproj

@@ -74,5 +74,8 @@
         <None Update="TestConfigs\v3\11-demo-config.yaml">
             <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
         </None>
+        <None Update="TestConfigs\v3\12-other.yaml">
+            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+        </None>
     </ItemGroup>
 </Project>

+ 25 - 0
Tests/schemas/schema.v3.json

@@ -102,6 +102,9 @@
         {
           "$ref": "#/$defs/ups"
         },
+        {
+          "$ref": "#/$defs/other"
+        },
         {
           "$ref": "#/$defs/desktop"
         },
@@ -582,6 +585,28 @@
       ],
       "unevaluatedProperties": false
     },
+    "other": {
+      "allOf": [
+        {
+          "$ref": "#/$defs/resourceBase"
+        },
+        {
+          "type": "object",
+          "properties": {
+            "kind": {
+              "const": "Other"
+            },
+            "model": {
+              "type": "string"
+            },
+            "description": {
+              "type": "string"
+            }
+          }
+        }
+      ],
+      "unevaluatedProperties": false
+    },
     "service": {
       "allOf": [
         {

+ 0 - 17
schemas/v2/schema.v2.json

@@ -53,7 +53,6 @@
         { "$ref": "#/$defs/switch" },
         { "$ref": "#/$defs/accessPoint" },
         { "$ref": "#/$defs/ups" },
-        { "$ref": "#/$defs/other" },
         { "$ref": "#/$defs/desktop" },
         { "$ref": "#/$defs/laptop" },
         { "$ref": "#/$defs/service" },
@@ -291,22 +290,6 @@
       "unevaluatedProperties": false
     },
 
-    "other": {
-      "allOf": [
-        { "$ref": "#/$defs/resourceBase" },
-        {
-          "type": "object",
-          "properties": {
-            "kind": { "const": "Other" },
-
-            "model": { "type": "string" },
-            "description": { "type": "string" }
-          }
-        }
-      ],
-      "unevaluatedProperties": false
-    },
-
     "service": {
       "allOf": [
         { "$ref": "#/$defs/resourceBase" },

+ 17 - 0
schemas/v3/schema.v3.json

@@ -53,6 +53,7 @@
         { "$ref": "#/$defs/switch" },
         { "$ref": "#/$defs/accessPoint" },
         { "$ref": "#/$defs/ups" },
+        { "$ref": "#/$defs/other" },
         { "$ref": "#/$defs/desktop" },
         { "$ref": "#/$defs/laptop" },
         { "$ref": "#/$defs/service" },
@@ -290,6 +291,22 @@
       "unevaluatedProperties": false
     },
 
+    "other": {
+      "allOf": [
+        { "$ref": "#/$defs/resourceBase" },
+        {
+          "type": "object",
+          "properties": {
+            "kind": { "const": "Other" },
+
+            "model": { "type": "string" },
+            "description": { "type": "string" }
+          }
+        }
+      ],
+      "unevaluatedProperties": false
+    },
+
     "service": {
       "allOf": [
         { "$ref": "#/$defs/resourceBase" },