(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func TestTemporalStore_WithIntervalTree(t *testing.T) { |
| 261 | store := NewTemporalStore() |
| 262 | |
| 263 | atom := ast.Atom{ |
| 264 | Predicate: ast.PredicateSym{Symbol: "test", Arity: 1}, |
| 265 | Args: []ast.BaseTerm{ast.String("alice")}, |
| 266 | } |
| 267 | |
| 268 | interval := makeTestInterval(100, 200) |
| 269 | |
| 270 | // Add fact |
| 271 | added, err := store.Add(atom, interval) |
| 272 | if err != nil { |
| 273 | t.Fatalf("Add failed: %v", err) |
| 274 | } |
| 275 | if !added { |
| 276 | t.Error("Expected Add to return true") |
| 277 | } |
| 278 | |
| 279 | // Check count |
| 280 | if store.EstimateFactCount() != 1 { |
| 281 | t.Errorf("Expected count 1, got %d", store.EstimateFactCount()) |
| 282 | } |
| 283 | |
| 284 | // Query at valid time |
| 285 | query := ast.NewQuery(atom.Predicate) |
| 286 | foundAt := false |
| 287 | store.GetFactsAt(query, time.Unix(0, 150), func(tf TemporalFact) error { |
| 288 | foundAt = true |
| 289 | return nil |
| 290 | }) |
| 291 | if !foundAt { |
| 292 | t.Error("Expected to find fact at valid time") |
| 293 | } |
| 294 | |
| 295 | // Query at invalid time |
| 296 | foundAt = false |
| 297 | store.GetFactsAt(query, time.Unix(0, 50), func(tf TemporalFact) error { |
| 298 | foundAt = true |
| 299 | return nil |
| 300 | }) |
| 301 | if foundAt { |
| 302 | t.Error("Did not expect to find fact at invalid time") |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | func TestTemporalStore_IntervalTreeLimit(t *testing.T) { |
| 307 | store := NewTemporalStore(WithMaxIntervalsPerAtom(3)) |
nothing calls this directly
no test coverage detected