Files
core/solutions/store/store_test.go
T
terminarandClaude Opus 5.5 2481a0dd27 solutions: Solutions Guide engine (catalog, rules, wizard state, native config, knowledge index, CLI)
New nested module yetano.dev/yetano/core/solutions: loads the catalog
in assets/solutions on top of the Big Picture, evaluates questions and
conditions, resolves packages/modules/capabilities, generates native
configuration from typed fragments with per-value origins, and builds
architecture graph, plan, lock file and handbook. Knowledge index with
yetano: references, search and lint (incl. manual sections). CLI with
yet's conventions (solution, task, knowledge, open), standalone as
yetano-solutions. No execution, no network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 08:42:58 +01:00

43 lines
1.2 KiB
Go

package store
import (
"errors"
"testing"
"yetano.dev/yetano/core/solutions/engine"
)
func TestStore(t *testing.T) {
s := Store{Dir: t.TempDir()}
if names, err := s.Instances(); err != nil || len(names) != 0 {
t.Fatal("empty store")
}
in := &engine.Instance{APIVersion: "yetano.dev/v1", Kind: "SolutionInstance", Metadata: engine.InstanceMeta{Name: "a"},
Spec: engine.InstanceSpec{Solution: engine.SolutionPin{ID: "x"}, Parameters: map[string]any{"k": "v"}}}
if err := s.SaveInstance(in); err != nil {
t.Fatal(err)
}
got, err := s.LoadInstance("a")
if err != nil || got.Spec.Parameters["k"] != "v" || got.Metadata.Created == "" {
t.Fatalf("%v %+v", err, got)
}
if _, err := s.LoadInstance("../a"); err == nil {
t.Error("path traversal accepted")
}
if _, err := s.LoadInstance("nope"); !errors.Is(err, ErrNotFound) {
t.Error(err)
}
if err := s.Touch("yetano:solution/x", "a"); err != nil {
t.Fatal(err)
}
s.Touch("yetano:solution/y", "")
s.Touch("yetano:solution/x", "a")
st, _ := s.LoadState()
if len(st.Recent) != 2 || st.Recent[0].Ref != "yetano:solution/x" {
t.Errorf("recent: %+v", st.Recent)
}
if err := s.DeleteInstance("a"); err != nil {
t.Fatal(err)
}
}