(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func 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 | |
| 161 | func TestFromMetadata(t *testing.T) { |
| 162 | original := NewProvenance(SourceUserInput, "session-789") |
nothing calls this directly
no test coverage detected