(t *testing.T)
| 210 | } |
| 211 | |
| 212 | func TestTemporalStore_GetFactsDuring(t *testing.T) { |
| 213 | store := NewTemporalStore() |
| 214 | |
| 215 | // Event from Jan 1-15 |
| 216 | event1 := ast.NewAtom("event", name("/conference")) |
| 217 | store.Add(event1, ast.TimeInterval( |
| 218 | ast.Date(2024, 1, 1), |
| 219 | ast.Date(2024, 1, 15), |
| 220 | )) |
| 221 | |
| 222 | // Event from Jan 20-30 |
| 223 | event2 := ast.NewAtom("event", name("/workshop")) |
| 224 | store.Add(event2, ast.TimeInterval( |
| 225 | ast.Date(2024, 1, 20), |
| 226 | ast.Date(2024, 1, 30), |
| 227 | )) |
| 228 | |
| 229 | tests := []struct { |
| 230 | name string |
| 231 | interval ast.Interval |
| 232 | wantCount int |
| 233 | }{ |
| 234 | { |
| 235 | name: "before all events", |
| 236 | interval: ast.TimeInterval( |
| 237 | ast.Date(2023, 12, 1), |
| 238 | ast.Date(2023, 12, 31), |
| 239 | ), |
| 240 | wantCount: 0, |
| 241 | }, |
| 242 | { |
| 243 | name: "overlaps first event", |
| 244 | interval: ast.TimeInterval( |
| 245 | ast.Date(2024, 1, 10), |
| 246 | ast.Date(2024, 1, 18), |
| 247 | ), |
| 248 | wantCount: 1, |
| 249 | }, |
| 250 | { |
| 251 | name: "overlaps both events", |
| 252 | interval: ast.TimeInterval( |
| 253 | ast.Date(2024, 1, 10), |
| 254 | ast.Date(2024, 1, 25), |
| 255 | ), |
| 256 | wantCount: 2, |
| 257 | }, |
| 258 | { |
| 259 | name: "between events (no overlap)", |
| 260 | interval: ast.TimeInterval( |
| 261 | ast.Date(2024, 1, 16), |
| 262 | ast.Date(2024, 1, 19), |
| 263 | ), |
| 264 | wantCount: 0, |
| 265 | }, |
| 266 | } |
| 267 | |
| 268 | query := ast.NewQuery(ast.PredicateSym{Symbol: "event", Arity: 1}) |
| 269 |
nothing calls this directly
no test coverage detected