(t *testing.T)
| 437 | } |
| 438 | |
| 439 | func TestTemporalFactStoreAdapter(t *testing.T) { |
| 440 | temporal := NewTemporalStore() |
| 441 | |
| 442 | // Add some temporal facts |
| 443 | alice := ast.NewAtom("employed", name("/alice")) |
| 444 | bob := ast.NewAtom("employed", name("/bob")) |
| 445 | |
| 446 | temporal.Add(alice, ast.TimeInterval( |
| 447 | ast.Date(2020, 1, 1), |
| 448 | ast.Date(2023, 12, 31), |
| 449 | )) |
| 450 | temporal.Add(bob, ast.TimeInterval( |
| 451 | ast.Date(2022, 1, 1), |
| 452 | ast.Date(2099, 12, 31), |
| 453 | )) |
| 454 | |
| 455 | // Test adapter without time constraint |
| 456 | adapter := NewTemporalFactStoreAdapter(temporal) |
| 457 | |
| 458 | query := ast.NewQuery(ast.PredicateSym{Symbol: "employed", Arity: 1}) |
| 459 | count := 0 |
| 460 | adapter.GetFacts(query, func(a ast.Atom) error { |
| 461 | count++ |
| 462 | return nil |
| 463 | }) |
| 464 | |
| 465 | if count != 2 { |
| 466 | t.Errorf("Adapter without time: count = %d, want 2", count) |
| 467 | } |
| 468 | |
| 469 | // Test adapter with time constraint |
| 470 | queryTime := ast.Date(2021, 6, 15) |
| 471 | adapterAt := NewTemporalFactStoreAdapterAt(temporal, queryTime) |
| 472 | |
| 473 | count = 0 |
| 474 | adapterAt.GetFacts(query, func(a ast.Atom) error { |
| 475 | count++ |
| 476 | return nil |
| 477 | }) |
| 478 | |
| 479 | if count != 1 { |
| 480 | t.Errorf("Adapter at 2021-06-15: count = %d, want 1 (only alice)", count) |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | func TestTemporalFactStoreAdapter_Add(t *testing.T) { |
| 485 | temporal := NewTemporalStore() |
nothing calls this directly
no test coverage detected