feat(apps): AppCatalogEntry record + test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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<string> Roles { get; init; } = Array.Empty<string>();
|
||||||
|
public IReadOnlyList<string> DefaultFor { get; init; } = Array.Empty<string>();
|
||||||
|
public string? Configure { get; init; }
|
||||||
|
|
||||||
|
public static readonly JsonSerializerOptions JsonOptions = new()
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true,
|
||||||
|
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||||
|
AllowTrailingCommas = true
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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<AppCatalogEntry>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user