MCPcopy
hub / github.com/google/mangle / TestTemporalStore_IntervalTreeLimit

Function TestTemporalStore_IntervalTreeLimit

factstore/interval_tree_test.go:306–327  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

304}
305
306func TestTemporalStore_IntervalTreeLimit(t *testing.T) {
307 store := NewTemporalStore(WithMaxIntervalsPerAtom(3))
308
309 atom := ast.Atom{
310 Predicate: ast.PredicateSym{Symbol: "test", Arity: 1},
311 Args: []ast.BaseTerm{ast.String("alice")},
312 }
313
314 // Add 3 intervals (should succeed)
315 for i := int64(0); i < 3; i++ {
316 _, err := store.Add(atom, makeTestInterval(i*100, i*100+50))
317 if err != nil {
318 t.Fatalf("Add %d failed: %v", i, err)
319 }
320 }
321
322 // 4th should fail
323 _, err := store.Add(atom, makeTestInterval(300, 350))
324 if err == nil {
325 t.Error("Expected error when exceeding interval limit")
326 }
327}
328
329// makeInterval creates an interval from start and end nanoseconds.
330func makeTestInterval(startNano, endNano int64) ast.Interval {

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
StringFunction · 0.92
NewTemporalStoreFunction · 0.85
WithMaxIntervalsPerAtomFunction · 0.85
makeTestIntervalFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected