MCPcopy Create free account
hub / github.com/astercloud/aster / TestProvenance_ToMetadata

Function TestProvenance_ToMetadata

pkg/memory/provenance_test.go:131–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func TestProvenance_ToMetadata(t *testing.T) {
132 p := NewProvenance(SourceUserInput, "session-123")
133 p.Tags = []string{"important", "customer"}
134
135 meta := p.ToMetadata()
136
137 provData, ok := meta["provenance"].(map[string]any)
138 if !ok {
139 t.Fatal("provenance not found in metadata")
140 }
141
142 if provData["source_type"] != string(SourceUserInput) {
143 t.Errorf("source_type = %v, want %v", provData["source_type"], SourceUserInput)
144 }
145
146 if provData["confidence"] != p.Confidence {
147 t.Errorf("confidence = %v, want %v", provData["confidence"], p.Confidence)
148 }
149
150 sources, ok := provData["sources"].([]string)
151 if !ok || len(sources) != 1 || sources[0] != "session-123" {
152 t.Errorf("sources = %v, want [session-123]", provData["sources"])
153 }
154
155 tags, ok := provData["tags"].([]string)
156 if !ok || len(tags) != 2 {
157 t.Errorf("tags = %v, want 2 tags", provData["tags"])
158 }
159}
160
161func TestFromMetadata(t *testing.T) {
162 original := NewProvenance(SourceUserInput, "session-789")

Callers

nothing calls this directly

Calls 2

NewProvenanceFunction · 0.85
ToMetadataMethod · 0.80

Tested by

no test coverage detected