(t *testing.T)
| 410 | } |
| 411 | |
| 412 | func TestIntegration_EternalFacts(t *testing.T) { |
| 413 | // Create a temporal store |
| 414 | store := factstore.NewTemporalStore() |
| 415 | |
| 416 | // Add an eternal fact (valid for all time) |
| 417 | admin := ast.NewAtom("admin", name("/root")) |
| 418 | store.AddEternal(admin) |
| 419 | |
| 420 | tests := []struct { |
| 421 | name string |
| 422 | evalTime time.Time |
| 423 | wantMatch bool |
| 424 | }{ |
| 425 | { |
| 426 | name: "Past: eternal fact is valid", |
| 427 | evalTime: ast.Date(1990, 1, 1), |
| 428 | wantMatch: true, |
| 429 | }, |
| 430 | { |
| 431 | name: "Present: eternal fact is valid", |
| 432 | evalTime: ast.Date(2024, 1, 1), |
| 433 | wantMatch: true, |
| 434 | }, |
| 435 | { |
| 436 | name: "Future: eternal fact is valid", |
| 437 | evalTime: ast.Date(2100, 1, 1), |
| 438 | wantMatch: true, |
| 439 | }, |
| 440 | } |
| 441 | |
| 442 | for _, test := range tests { |
| 443 | t.Run(test.name, func(t *testing.T) { |
| 444 | te := NewTemporalEvaluator(store, test.evalTime) |
| 445 | |
| 446 | query := ast.NewAtom("admin", name("/root")) |
| 447 | tl := ast.TemporalLiteral{ |
| 448 | Literal: query, |
| 449 | Operator: nil, |
| 450 | Interval: nil, |
| 451 | } |
| 452 | |
| 453 | solutions, err := te.EvalTemporalLiteral(tl, unionfind.New()) |
| 454 | if err != nil { |
| 455 | t.Fatalf("EvalTemporalLiteral failed: %v", err) |
| 456 | } |
| 457 | |
| 458 | gotMatch := len(solutions) > 0 |
| 459 | if gotMatch != test.wantMatch { |
| 460 | t.Errorf("Got match = %v, want %v", gotMatch, test.wantMatch) |
| 461 | } |
| 462 | }) |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | func TestIntegration_IntervalFunctions(t *testing.T) { |
| 467 | // Test the interval extraction functions |
nothing calls this directly
no test coverage detected