CLI (add, remove, list, outdated, update, import) over a skills.json manifest and a skills.lock.json pinned with nix flake prefetch, plus a home-manager module that links each locked skill via builtins.fetchTree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package manifest
|
|
|
|
import (
|
|
"encoding/json"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSelectionJSON(t *testing.T) {
|
|
cases := []struct {
|
|
json string
|
|
sel Selection
|
|
}{
|
|
{`"*"`, Selection{All: true}},
|
|
{`[]`, Selection{}},
|
|
{`["tdd",{"name":"grilling","as":"grilling-mp"}]`, Selection{Items: []Skill{
|
|
{Name: "tdd"},
|
|
{Name: "grilling", As: "grilling-mp"},
|
|
}}},
|
|
}
|
|
for _, c := range cases {
|
|
var got Selection
|
|
if err := json.Unmarshal([]byte(c.json), &got); err != nil {
|
|
t.Fatalf("unmarshal %s: %v", c.json, err)
|
|
}
|
|
if c.sel.Items == nil && got.Items != nil && len(got.Items) == 0 {
|
|
got.Items = nil
|
|
}
|
|
if !reflect.DeepEqual(got, c.sel) {
|
|
t.Errorf("unmarshal %s = %+v, want %+v", c.json, got, c.sel)
|
|
}
|
|
out, err := json.Marshal(c.sel)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(out) != c.json {
|
|
t.Errorf("marshal %+v = %s, want %s", c.sel, out, c.json)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSelectionRejectsOtherStrings(t *testing.T) {
|
|
var s Selection
|
|
if err := json.Unmarshal([]byte(`"tdd"`), &s); err == nil {
|
|
t.Error("want error for a bare skill name")
|
|
}
|
|
}
|