From bfb53bd295318e321aed7934041b21e94bf03446 Mon Sep 17 00:00:00 2001 From: sysadmin Date: Wed, 10 Jun 2026 00:16:10 +0100 Subject: [PATCH] feat(apps): AppCatalogEntry record + test Co-Authored-By: Claude Sonnet 4.6 --- .../Apps/AppCatalogEntry.cs | 28 +++++++++++++++++++ .../SilverOS.Welcome.Tests/AppCatalogTests.cs | 21 ++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 windows/welcome/src/SilverOS.Welcome.Core/Apps/AppCatalogEntry.cs create mode 100644 windows/welcome/tests/SilverOS.Welcome.Tests/AppCatalogTests.cs diff --git a/windows/welcome/src/SilverOS.Welcome.Core/Apps/AppCatalogEntry.cs b/windows/welcome/src/SilverOS.Welcome.Core/Apps/AppCatalogEntry.cs new file mode 100644 index 0000000..5a886d8 --- /dev/null +++ b/windows/welcome/src/SilverOS.Welcome.Core/Apps/AppCatalogEntry.cs @@ -0,0 +1,28 @@ +using System.Text.Json; + +namespace SilverOS.Welcome.Core.Apps; + +public sealed record AppSource +{ + public string? Winget { get; init; } + // Future: public string? Mirror { get; init; } // swappable to a curated mirror. +} + +public sealed record AppCatalogEntry +{ + public string Id { get; init; } = ""; + public string Name { get; init; } = ""; + public string Description { get; init; } = ""; + public AppSource Source { get; init; } = new(); + public string Group { get; init; } = ""; + public IReadOnlyList Roles { get; init; } = Array.Empty(); + public IReadOnlyList DefaultFor { get; init; } = Array.Empty(); + public string? Configure { get; init; } + + public static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true, + ReadCommentHandling = JsonCommentHandling.Skip, + AllowTrailingCommas = true + }; +} diff --git a/windows/welcome/tests/SilverOS.Welcome.Tests/AppCatalogTests.cs b/windows/welcome/tests/SilverOS.Welcome.Tests/AppCatalogTests.cs new file mode 100644 index 0000000..ce77a50 --- /dev/null +++ b/windows/welcome/tests/SilverOS.Welcome.Tests/AppCatalogTests.cs @@ -0,0 +1,21 @@ +using System.Text.Json; +using SilverOS.Welcome.Core.Apps; +using Xunit; + +public class AppCatalogTests +{ + [Fact] + public void Deserializes_a_catalog_entry() + { + var json = """ + { "id":"vscodium","name":"VSCodium","description":"Telemetry-free VS Code.", + "source":{"winget":"VSCodium.VSCodium"},"group":"developer", + "roles":["developer"],"defaultFor":["developer"],"configure":null } + """; + var e = JsonSerializer.Deserialize(json, AppCatalogEntry.JsonOptions)!; + Assert.Equal("vscodium", e.Id); + Assert.Equal("VSCodium.VSCodium", e.Source.Winget); + Assert.Contains("developer", e.Roles); + Assert.Contains("developer", e.DefaultFor); + } +}