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 <noreply@anthropic.com>
This commit is contained in:
parent
ed365f9030
commit
d53c3d8325
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user