From d53c3d83253a694b42464032c0f3043d8df6e56b Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Sun, 7 Jun 2026 15:23:05 +0800 Subject: [PATCH] feat(plugin): add Tags field to ModPlugin TDD approach: added failing tests in mod_test.go that check parsing and null-coalescing of tags, then added the []string Tags field to ModPlugin struct with TOML tag "tags,omitempty". Co-Authored-By: Claude Opus 4.7 --- plugin/mod.go | 1 + plugin/mod_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/plugin/mod.go b/plugin/mod.go index e95ea16..7f986e4 100644 --- a/plugin/mod.go +++ b/plugin/mod.go @@ -32,6 +32,7 @@ type ModPlugin struct { Version string `toml:"version"` Kind string `toml:"kind,omitempty"` Categories []string `toml:"categories,omitempty"` + Tags []string `toml:"tags,omitempty"` // RequiredIconPacks names icon-pack slugs the host CMS must ensure are // installed before the plugin is loaded (e.g. "tabler", "phosphor"). The // standalone-plugin loader honours this best-effort by auto-installing any diff --git a/plugin/mod_test.go b/plugin/mod_test.go index b0de68b..a324a6f 100644 --- a/plugin/mod_test.go +++ b/plugin/mod_test.go @@ -365,3 +365,39 @@ func TestNormalizeTags_NilInput(t *testing.T) { t.Errorf("got %v, want empty", got) } } + +func TestParseModFull_Tags(t *testing.T) { + src := []byte(` +[plugin] +name = "dark-pro" +scope = "themes" +version = "0.1.0" +kind = "theme" +tags = ["dark", "agency", "serif"] +`) + m, err := ParseModFull(src) + if err != nil { + t.Fatalf("ParseModFull err: %v", err) + } + if len(m.Plugin.Tags) != 3 { + t.Fatalf("Tags len = %d, want 3 (%v)", len(m.Plugin.Tags), m.Plugin.Tags) + } + if m.Plugin.Tags[0] != "dark" || m.Plugin.Tags[1] != "agency" || m.Plugin.Tags[2] != "serif" { + t.Errorf("Tags = %v", m.Plugin.Tags) + } +} + +func TestParseModFull_TagsOmittedIsNil(t *testing.T) { + src := []byte(` +[plugin] +name = "no-tags" +version = "0.1.0" +`) + m, err := ParseModFull(src) + if err != nil { + t.Fatalf("err: %v", err) + } + if m.Plugin.Tags != nil { + t.Errorf("Tags = %v, want nil when omitted", m.Plugin.Tags) + } +}