(t *testing.T)
| 186 | } |
| 187 | |
| 188 | func TestIntegration_TemporalStoreAndQuery(t *testing.T) { |
| 189 | // Create a temporal store |
| 190 | store := factstore.NewTemporalStore() |
| 191 | |
| 192 | // Add temporal facts |
| 193 | aliceActive := ast.NewAtom("active", name("/alice")) |
| 194 | bobActive := ast.NewAtom("active", name("/bob")) |
| 195 | |
| 196 | // Alice was active from Jan 1-15, 2024 |
| 197 | store.Add(aliceActive, ast.TimeInterval( |
| 198 | ast.Date(2024, 1, 1), |
| 199 | ast.Date(2024, 1, 15), |
| 200 | )) |
| 201 | |
| 202 | // Bob is active from Jan 10-31, 2024 |
| 203 | store.Add(bobActive, ast.TimeInterval( |
| 204 | ast.Date(2024, 1, 10), |
| 205 | ast.Date(2024, 1, 31), |
| 206 | )) |
| 207 | |
| 208 | tests := []struct { |
| 209 | name string |
| 210 | evalTime time.Time |
| 211 | wantActive []string |
| 212 | }{ |
| 213 | { |
| 214 | name: "Jan 5: only Alice active", |
| 215 | evalTime: ast.Date(2024, 1, 5), |
| 216 | wantActive: []string{"/alice"}, |
| 217 | }, |
| 218 | { |
| 219 | name: "Jan 12: both active", |
| 220 | evalTime: ast.Date(2024, 1, 12), |
| 221 | wantActive: []string{"/alice", "/bob"}, |
| 222 | }, |
| 223 | { |
| 224 | name: "Jan 20: only Bob active", |
| 225 | evalTime: ast.Date(2024, 1, 20), |
| 226 | wantActive: []string{"/bob"}, |
| 227 | }, |
| 228 | { |
| 229 | name: "Feb 1: no one active", |
| 230 | evalTime: ast.Date(2024, 2, 1), |
| 231 | wantActive: []string{}, |
| 232 | }, |
| 233 | } |
| 234 | |
| 235 | for _, test := range tests { |
| 236 | t.Run(test.name, func(t *testing.T) { |
| 237 | te := NewTemporalEvaluator(store, test.evalTime) |
| 238 | |
| 239 | query := ast.NewAtom("active", ast.Variable{Symbol: "X"}) |
| 240 | tl := ast.TemporalLiteral{ |
| 241 | Literal: query, |
| 242 | Operator: nil, |
| 243 | Interval: nil, |
| 244 | } |
| 245 |
nothing calls this directly
no test coverage detected