(t *testing.T)
| 268 | } |
| 269 | |
| 270 | func TestIntegration_DiamondMinusQuery(t *testing.T) { |
| 271 | // Create a temporal store |
| 272 | store := factstore.NewTemporalStore() |
| 273 | |
| 274 | // Add a fact: employee was on_leave from Jan 5-10, 2024 |
| 275 | onLeave := ast.NewAtom("on_leave", name("/alice")) |
| 276 | store.Add(onLeave, ast.TimeInterval( |
| 277 | ast.Date(2024, 1, 5), |
| 278 | ast.Date(2024, 1, 10), |
| 279 | )) |
| 280 | |
| 281 | tests := []struct { |
| 282 | name string |
| 283 | evalTime time.Time |
| 284 | lookbackDays int |
| 285 | wantMatch bool |
| 286 | }{ |
| 287 | { |
| 288 | name: "Jan 15: within 30 day lookback", |
| 289 | evalTime: ast.Date(2024, 1, 15), |
| 290 | lookbackDays: 30, |
| 291 | wantMatch: true, |
| 292 | }, |
| 293 | { |
| 294 | name: "Jan 15: within 10 day lookback (barely)", |
| 295 | evalTime: ast.Date(2024, 1, 15), |
| 296 | lookbackDays: 10, |
| 297 | wantMatch: true, |
| 298 | }, |
| 299 | { |
| 300 | name: "Jan 15: 3 day lookback misses it", |
| 301 | evalTime: ast.Date(2024, 1, 15), |
| 302 | lookbackDays: 3, |
| 303 | wantMatch: false, |
| 304 | }, |
| 305 | { |
| 306 | name: "Feb 15: 30 day lookback misses it", |
| 307 | evalTime: ast.Date(2024, 2, 15), |
| 308 | lookbackDays: 30, |
| 309 | wantMatch: false, |
| 310 | }, |
| 311 | } |
| 312 | |
| 313 | for _, test := range tests { |
| 314 | t.Run(test.name, func(t *testing.T) { |
| 315 | te := NewTemporalEvaluator(store, test.evalTime) |
| 316 | |
| 317 | query := ast.NewAtom("on_leave", name("/alice")) |
| 318 | operator := ast.TemporalOperator{ |
| 319 | Type: ast.DiamondMinus, |
| 320 | Interval: ast.NewInterval( |
| 321 | ast.NewDurationBound(0), // ~now |
| 322 | ast.NewDurationBound(time.Duration(test.lookbackDays)*24*time.Hour), |
| 323 | ), |
| 324 | } |
| 325 | |
| 326 | tl := ast.TemporalLiteral{ |
| 327 | Literal: query, |
nothing calls this directly
no test coverage detected